home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / gawk-3.000 / gawk-3 / gawk-3.0.0 / awktab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-31  |  113.6 KB  |  3,800 lines

  1.  
  2. /*  A Bison parser, made from ./awk.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    FUNC_CALL    258
  8. #define    NAME    259
  9. #define    REGEXP    260
  10. #define    ERROR    261
  11. #define    YNUMBER    262
  12. #define    YSTRING    263
  13. #define    RELOP    264
  14. #define    APPEND_OP    265
  15. #define    ASSIGNOP    266
  16. #define    MATCHOP    267
  17. #define    NEWLINE    268
  18. #define    CONCAT_OP    269
  19. #define    LEX_BEGIN    270
  20. #define    LEX_END    271
  21. #define    LEX_IF    272
  22. #define    LEX_ELSE    273
  23. #define    LEX_RETURN    274
  24. #define    LEX_DELETE    275
  25. #define    LEX_WHILE    276
  26. #define    LEX_DO    277
  27. #define    LEX_FOR    278
  28. #define    LEX_BREAK    279
  29. #define    LEX_CONTINUE    280
  30. #define    LEX_PRINT    281
  31. #define    LEX_PRINTF    282
  32. #define    LEX_NEXT    283
  33. #define    LEX_EXIT    284
  34. #define    LEX_FUNCTION    285
  35. #define    LEX_GETLINE    286
  36. #define    LEX_NEXTFILE    287
  37. #define    LEX_IN    288
  38. #define    LEX_AND    289
  39. #define    LEX_OR    290
  40. #define    INCREMENT    291
  41. #define    DECREMENT    292
  42. #define    LEX_BUILTIN    293
  43. #define    LEX_LENGTH    294
  44. #define    UNARY    295
  45.  
  46. #line 26 "./awk.y"
  47.  
  48. #ifdef DEBUG
  49. #define YYDEBUG 12
  50. #endif
  51.  
  52. #include "awk.h"
  53.  
  54. #define CAN_FREE    TRUE
  55. #define DONT_FREE    FALSE
  56.  
  57. #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
  58. static void yyerror(const char *m, ...) ;
  59. #else
  60. static void yyerror(); /* va_alist */
  61. #endif
  62. static char *get_src_buf P((void));
  63. static int yylex P((void));
  64. static NODE *node_common P((NODETYPE op));
  65. static NODE *snode P((NODE *subn, NODETYPE op, int sindex));
  66. static NODE *mkrangenode P((NODE *cpair));
  67. static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr));
  68. static NODE *append_right P((NODE *list, NODE *new));
  69. static void func_install P((NODE *params, NODE *def));
  70. static void pop_var P((NODE *np, int freeit));
  71. static void pop_params P((NODE *params));
  72. static NODE *make_param P((char *name));
  73. static NODE *mk_rexp P((NODE *exp));
  74. static int dup_parms P((NODE *func));
  75. static void param_sanity P((NODE *arglist));
  76. static int isnoeffect P((NODETYPE));
  77.  
  78. enum defref { FUNC_DEFINE, FUNC_USE };
  79. static void func_use P((char *name, enum defref how));
  80. static void check_funcs P((void));
  81.  
  82. static int want_assign;        /* lexical scanning kludge */
  83. static int want_regexp;        /* lexical scanning kludge */
  84. static int can_return;        /* lexical scanning kludge */
  85. static int io_allowed = TRUE;    /* lexical scanning kludge */
  86. static char *lexptr;        /* pointer to next char during parsing */
  87. static char *lexend;
  88. static char *lexptr_begin;    /* keep track of where we were for error msgs */
  89. static char *lexeme;        /* beginning of lexeme for debugging */
  90. static char *thisline = NULL;
  91. #define YYDEBUG_LEXER_TEXT (lexeme)
  92. static int param_counter;
  93. static char *tokstart = NULL;
  94. static char *tok = NULL;
  95. static char *tokend;
  96.  
  97. #define HASHSIZE    1021    /* this constant only used here */
  98. NODE *variables[HASHSIZE];
  99.  
  100. extern char *source;
  101. extern int sourceline;
  102. extern struct src *srcfiles;
  103. extern int numfiles;
  104. extern int errcount;
  105. extern NODE *begin_block;
  106. extern NODE *end_block;
  107.  
  108. #line 88 "./awk.y"
  109. typedef union {
  110.     long lval;
  111.     AWKNUM fval;
  112.     NODE *nodeval;
  113.     NODETYPE nodetypeval;
  114.     char *sval;
  115.     NODE *(*ptrval)();
  116. } YYSTYPE;
  117.  
  118. #ifndef YYLTYPE
  119. typedef
  120.   struct yyltype
  121.     {
  122.       int timestamp;
  123.       int first_line;
  124.       int first_column;
  125.       int last_line;
  126.       int last_column;
  127.       char *text;
  128.    }
  129.   yyltype;
  130.  
  131. #define YYLTYPE yyltype
  132. #endif
  133.  
  134. #include <stdio.h>
  135.  
  136. #ifndef __cplusplus
  137. #ifndef __STDC__
  138. #define const
  139. #endif
  140. #endif
  141.  
  142.  
  143.  
  144. #define    YYFINAL        312
  145. #define    YYFLAG        -32768
  146. #define    YYNTBASE    62
  147.  
  148. #define YYTRANSLATE(x) ((unsigned)(x) <= 295 ? yytranslate[x] : 107)
  149.  
  150. static const char yytranslate[] = {     0,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,    51,     2,     2,    54,    50,     2,     2,    55,
  155.     56,    48,    46,    42,    47,     2,    49,     2,     2,     2,
  156.      2,     2,     2,     2,     2,     2,     2,    41,    61,    43,
  157.      2,    44,    40,     2,     2,     2,     2,     2,     2,     2,
  158.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  159.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  160.     57,     2,    58,    53,     2,     2,     2,     2,     2,     2,
  161.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  162.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  163.      2,     2,    59,    45,    60,     2,     2,     2,     2,     2,
  164.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  165.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  166.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  167.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  168.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  169.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  170.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  171.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  172.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  173.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  174.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  175.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  177.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  178.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  179.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  180.     36,    37,    38,    39,    52
  181. };
  182.  
  183. #if YYDEBUG != 0
  184. static const short yyprhs[] = {     0,
  185.      0,     4,     6,     9,    11,    14,    15,    16,    20,    21,
  186.     25,    28,    31,    34,    36,    39,    42,    44,    46,    48,
  187.     50,    52,    53,    61,    66,    71,    73,    77,    78,    83,
  188.     89,    94,    96,    99,   101,   104,   106,   109,   112,   115,
  189.    119,   121,   128,   137,   146,   157,   167,   170,   173,   180,
  190.    185,   189,   192,   196,   197,   202,   209,   213,   216,   218,
  191.    220,   227,   237,   239,   242,   243,   245,   246,   249,   250,
  192.    253,   256,   259,   260,   262,   264,   268,   270,   273,   277,
  193.    278,   280,   281,   283,   285,   289,   291,   294,   298,   302,
  194.    303,   305,   307,   311,   313,   316,   320,   324,   325,   330,
  195.    336,   341,   345,   349,   353,   357,   359,   362,   366,   370,
  196.    374,   378,   384,   386,   389,   390,   395,   399,   403,   407,
  197.    409,   412,   416,   420,   424,   430,   432,   435,   437,   441,
  198.    445,   449,   453,   457,   461,   464,   467,   470,   474,   479,
  199.    484,   486,   491,   493,   496,   499,   501,   503,   506,   509,
  200.    510,   512,   514,   519,   522,   525,   528,   530,   531,   533,
  201.    535
  202. };
  203.  
  204. static const short yyrhs[] = {    83,
  205.     63,    83,     0,    64,     0,    63,    64,     0,     1,     0,
  206.     63,     1,     0,     0,     0,    15,    65,    75,     0,     0,
  207.     16,    66,    75,     0,    15,    77,     0,    16,    77,     0,
  208.     72,    75,     0,    75,     0,    72,    77,     0,    69,    71,
  209.      0,     4,     0,     3,     0,    68,     0,    38,     0,    39,
  210.      0,     0,    30,    70,    67,    55,    86,   103,    83,     0,
  211.    101,    76,   102,   104,     0,   101,   102,   104,    83,     0,
  212.     93,     0,    93,    42,    93,     0,     0,    49,    74,     5,
  213.     49,     0,   101,    76,   102,   104,    83,     0,   101,   102,
  214.    104,    83,     0,    78,     0,    76,    78,     0,     1,     0,
  215.     76,     1,     0,    82,     0,   105,    83,     0,   105,    83,
  216.      0,   101,   102,     0,   101,    76,   102,     0,    81,     0,
  217.     21,    55,    93,   103,    83,    78,     0,    22,    83,    78,
  218.     21,    55,    93,   103,    83,     0,    23,    55,     4,    33,
  219.      4,   103,    83,    78,     0,    23,    55,    88,   105,    93,
  220.    105,    88,   103,    83,    78,     0,    23,    55,    88,   105,
  221.    105,    88,   103,    83,    78,     0,    24,    77,     0,    25,
  222.     77,     0,    80,    55,    92,   103,    85,    77,     0,    80,
  223.     89,    85,    77,     0,    28,    88,    77,     0,    32,    77,
  224.      0,    29,    88,    77,     0,     0,    19,    79,    88,    77,
  225.      0,    20,     4,    57,    92,    58,    77,     0,    20,     4,
  226.     77,     0,    93,    77,     0,    26,     0,    27,     0,    17,
  227.     55,    93,   103,    83,    78,     0,    17,    55,    93,   103,
  228.     83,    78,    18,    83,    78,     0,    13,     0,    82,    13,
  229.      0,     0,    82,     0,     0,    43,    97,     0,     0,    44,
  230.     93,     0,    10,    93,     0,    45,    93,     0,     0,    87,
  231.      0,     4,     0,    87,   106,     4,     0,     1,     0,    87,
  232.      1,     0,    87,   106,     1,     0,     0,    93,     0,     0,
  233.     90,     0,    95,     0,    90,   106,    95,     0,     1,     0,
  234.     90,     1,     0,    90,     1,    95,     0,    90,   106,     1,
  235.      0,     0,    92,     0,    93,     0,    92,   106,    93,     0,
  236.      1,     0,    92,     1,     0,    92,     1,    93,     0,    92,
  237.    106,     1,     0,     0,   100,    11,    94,    93,     0,    55,
  238.     92,   103,    33,     4,     0,    93,    45,    31,    99,     0,
  239.     31,    99,    84,     0,    93,    34,    93,     0,    93,    35,
  240.     93,     0,    93,    12,    93,     0,    73,     0,    51,    73,
  241.      0,    93,    33,     4,     0,    93,     9,    93,     0,    93,
  242.     43,    93,     0,    93,    44,    93,     0,    93,    40,    93,
  243.     41,    93,     0,    97,     0,    93,    97,     0,     0,   100,
  244.     11,    96,    95,     0,    95,    34,    95,     0,    95,    35,
  245.     95,     0,    31,    99,    84,     0,    73,     0,    51,    73,
  246.      0,    95,    12,    95,     0,    95,    33,     4,     0,    95,
  247.      9,    95,     0,    95,    40,    95,    41,    95,     0,    97,
  248.      0,    95,    97,     0,    98,     0,    97,    53,    97,     0,
  249.     97,    48,    97,     0,    97,    49,    97,     0,    97,    50,
  250.     97,     0,    97,    46,    97,     0,    97,    47,    97,     0,
  251.    100,    36,     0,   100,    37,     0,    51,    97,     0,    55,
  252.     93,   103,     0,    38,    55,    91,   103,     0,    39,    55,
  253.     91,   103,     0,    39,     0,     3,    55,    91,   103,     0,
  254.    100,     0,    36,   100,     0,    37,   100,     0,     7,     0,
  255.      8,     0,    47,    97,     0,    46,    97,     0,     0,   100,
  256.      0,     4,     0,     4,    57,    92,    58,     0,    54,    98,
  257.      0,    59,    83,     0,    60,    83,     0,    56,     0,     0,
  258.    105,     0,    61,     0,    42,    83,     0
  259. };
  260.  
  261. #endif
  262.  
  263. #if YYDEBUG != 0
  264. static const short yyrline[] = { 0,
  265.    149,   157,   165,   181,   182,   183,   187,   189,   203,   205,
  266.    219,   225,   231,   233,   235,   248,   257,   259,   261,   271,
  267.    272,   276,   280,   291,   296,   305,   307,   316,   318,   336,
  268.    338,   343,   349,   357,   359,   364,   365,   369,   371,   373,
  269.    375,   377,   379,   381,   387,   391,   396,   399,   402,   404,
  270.    424,   463,   482,   484,   489,   491,   493,   507,   512,   514,
  271.    519,   524,   531,   533,   537,   538,   542,   544,   549,   551,
  272.    553,   555,   560,   562,   567,   569,   571,   573,   575,   581,
  273.    583,   588,   590,   595,   597,   603,   605,   607,   609,   614,
  274.    616,   621,   623,   629,   631,   633,   635,   640,   643,   648,
  275.    650,   655,   661,   663,   665,   671,   681,   689,   691,   697,
  276.    699,   701,   703,   705,   710,   713,   714,   716,   718,   724,
  277.    726,   728,   730,   732,   734,   736,   738,   743,   745,   747,
  278.    749,   751,   753,   755,   757,   759,   764,   766,   768,   771,
  279.    773,   781,   788,   789,   791,   793,   795,   798,   806,   817,
  280.    819,   824,   826,   834,   839,   843,   847,   851,   852,   856,
  281.    859
  282. };
  283.  
  284. static const char * const yytname[] = {   "$","error","$illegal.","FUNC_CALL",
  285. "NAME","REGEXP","ERROR","YNUMBER","YSTRING","RELOP","APPEND_OP","ASSIGNOP","MATCHOP",
  286. "NEWLINE","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN",
  287. "LEX_DELETE","LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT",
  288. "LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION","LEX_GETLINE","LEX_NEXTFILE",
  289. "LEX_IN","LEX_AND","LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","LEX_LENGTH",
  290. "'?'","':'","','","'<'","'>'","'|'","'+'","'-'","'*'","'/'","'%'","'!'","UNARY",
  291. "'^'","'$'","'('","')'","'['","']'","'{'","'}'","';'","start","program","rule",
  292. "@1","@2","func_name","lex_builtin","function_prologue","@3","function_body",
  293. "pattern","regexp","@4","action","statements","statement_term","statement","@5",
  294. "print","if_statement","nls","opt_nls","input_redir","output_redir","opt_param_list",
  295. "param_list","opt_exp","opt_rexpression_list","rexpression_list","opt_expression_list",
  296. "expression_list","exp","@6","rexp","@7","simp_exp","non_post_simp_exp","opt_variable",
  297. "variable","l_brace","r_brace","r_paren","opt_semi","semi","comma",""
  298. };
  299. #endif
  300.  
  301. static const short yyr1[] = {     0,
  302.     62,    63,    63,    63,    63,    63,    65,    64,    66,    64,
  303.     64,    64,    64,    64,    64,    64,    67,    67,    67,    68,
  304.     68,    70,    69,    71,    71,    72,    72,    74,    73,    75,
  305.     75,    76,    76,    76,    76,    77,    77,    78,    78,    78,
  306.     78,    78,    78,    78,    78,    78,    78,    78,    78,    78,
  307.     78,    78,    78,    79,    78,    78,    78,    78,    80,    80,
  308.     81,    81,    82,    82,    83,    83,    84,    84,    85,    85,
  309.     85,    85,    86,    86,    87,    87,    87,    87,    87,    88,
  310.     88,    89,    89,    90,    90,    90,    90,    90,    90,    91,
  311.     91,    92,    92,    92,    92,    92,    92,    94,    93,    93,
  312.     93,    93,    93,    93,    93,    93,    93,    93,    93,    93,
  313.     93,    93,    93,    93,    96,    95,    95,    95,    95,    95,
  314.     95,    95,    95,    95,    95,    95,    95,    97,    97,    97,
  315.     97,    97,    97,    97,    97,    97,    98,    98,    98,    98,
  316.     98,    98,    98,    98,    98,    98,    98,    98,    98,    99,
  317.     99,   100,   100,   100,   101,   102,   103,   104,   104,   105,
  318.    106
  319. };
  320.  
  321. static const short yyr2[] = {     0,
  322.      3,     1,     2,     1,     2,     0,     0,     3,     0,     3,
  323.      2,     2,     2,     1,     2,     2,     1,     1,     1,     1,
  324.      1,     0,     7,     4,     4,     1,     3,     0,     4,     5,
  325.      4,     1,     2,     1,     2,     1,     2,     2,     2,     3,
  326.      1,     6,     8,     8,    10,     9,     2,     2,     6,     4,
  327.      3,     2,     3,     0,     4,     6,     3,     2,     1,     1,
  328.      6,     9,     1,     2,     0,     1,     0,     2,     0,     2,
  329.      2,     2,     0,     1,     1,     3,     1,     2,     3,     0,
  330.      1,     0,     1,     1,     3,     1,     2,     3,     3,     0,
  331.      1,     1,     3,     1,     2,     3,     3,     0,     4,     5,
  332.      4,     3,     3,     3,     3,     1,     2,     3,     3,     3,
  333.      3,     5,     1,     2,     0,     4,     3,     3,     3,     1,
  334.      2,     3,     3,     3,     5,     1,     2,     1,     3,     3,
  335.      3,     3,     3,     3,     2,     2,     2,     3,     4,     4,
  336.      1,     4,     1,     2,     2,     1,     1,     2,     2,     0,
  337.      1,     1,     4,     2,     2,     2,     1,     0,     1,     1,
  338.      2
  339. };
  340.  
  341. static const short yydefact[] = {    65,
  342.     63,    66,     0,    64,     4,     0,   152,   146,   147,     7,
  343.      9,    22,   150,     0,     0,     0,   141,     0,     0,    28,
  344.      0,     0,     0,    65,     0,     2,     0,     0,   106,    14,
  345.     26,   113,   128,   143,     0,     0,     0,   160,     0,    11,
  346.     36,    65,     0,    12,     0,    67,   151,   144,   145,     0,
  347.      0,     0,     0,   149,   143,   148,     0,   107,   137,   154,
  348.    143,    94,     0,    92,   155,     5,     3,     1,    16,     0,
  349.     13,    15,     0,     0,     0,     0,     0,     0,     0,     0,
  350.      0,     0,   114,     0,     0,     0,     0,     0,     0,    98,
  351.    135,   136,    34,     0,    54,     0,     0,    65,     0,     0,
  352.      0,    59,    60,    80,    80,     0,    65,     0,    32,     0,
  353.     41,     0,     0,   158,    65,     0,     0,    92,     0,     8,
  354.     37,    10,    18,    17,    20,    21,     0,    19,     0,   102,
  355.      0,     0,     0,     0,    95,    65,   157,     0,     0,   138,
  356.      0,   158,   109,   105,   108,   103,   104,     0,    27,   110,
  357.    111,   150,   133,   134,   130,   131,   132,   129,     0,     0,
  358.     80,     0,     0,     0,    80,    47,    48,     0,    81,     0,
  359.     52,   156,    35,    33,   158,    86,   150,     0,     0,   120,
  360.     69,     0,    84,   126,   143,    58,     0,    39,    65,   159,
  361.     38,   142,   153,     0,    68,   139,   140,    29,    96,   161,
  362.      0,    97,    93,   158,    65,     0,   101,    99,     0,     0,
  363.      0,    57,     0,     0,   152,     0,    51,    53,    65,    67,
  364.    121,     0,     0,     0,     0,     0,    87,     0,     0,     0,
  365.      0,     0,     0,     0,   127,   115,    40,    31,    77,    75,
  366.      0,     0,   100,    24,    25,   112,    65,    55,     0,    65,
  367.      0,     0,     0,    30,   119,    69,    71,    70,    72,    50,
  368.     88,    89,    85,   124,   122,   123,   117,   118,     0,     0,
  369.     65,    78,     0,     0,     0,     0,     0,     0,     0,    80,
  370.      0,     0,   116,    23,    79,    76,    61,    56,    42,     0,
  371.     65,    80,     0,    49,   125,    65,    65,     0,     0,    65,
  372.      0,    43,    44,    65,     0,    62,     0,    46,    45,     0,
  373.      0,     0
  374. };
  375.  
  376. static const short yydefgoto[] = {   310,
  377.     25,    26,    39,    43,   127,   128,    27,    45,    69,    28,
  378.     29,    57,    30,   108,    40,   109,   161,   110,   111,     2,
  379.      3,   130,   226,   241,   242,   168,   181,   182,   116,   117,
  380.    112,   159,   183,   270,    32,    33,    46,    34,   113,   114,
  381.    140,   189,    42,   139
  382. };
  383.  
  384. static const short yypact[] = {    -6,
  385. -32768,     0,   875,-32768,-32768,   -40,   -38,-32768,-32768,    -7,
  386.     -7,-32768,    10,    10,    10,   -31,   -26,  1735,  1735,-32768,
  387.   1715,  1735,  1131,    -6,   932,-32768,   -24,    72,-32768,-32768,
  388.   1304,   205,-32768,     5,   709,  1110,  1131,-32768,   -24,-32768,
  389.      0,    -6,   -24,-32768,    85,     3,-32768,-32768,-32768,  1110,
  390.   1110,  1735,  1620,     8,   106,     8,    81,-32768,     8,-32768,
  391. -32768,-32768,    37,  1250,-32768,-32768,-32768,-32768,-32768,   709,
  392. -32768,-32768,  1620,  1620,    90,  1620,  1620,  1620,  1620,  1620,
  393.   1620,    65,   205,  1735,  1735,  1735,  1735,  1735,  1735,-32768,
  394. -32768,-32768,-32768,    50,-32768,   111,    70,    -6,    93,    -7,
  395.     -7,-32768,-32768,  1620,  1620,    -7,    -6,   758,-32768,   819,
  396. -32768,  1040,   709,   100,    -6,    99,    55,  1402,     9,-32768,
  397. -32768,-32768,-32768,-32768,-32768,-32768,   109,-32768,  1735,-32768,
  398.     99,    99,  1250,   119,  1620,    -6,-32768,   133,  1180,-32768,
  399.    758,   100,  1327,   794,-32768,  1515,  1451,  1353,  1402,  1327,
  400.   1327,    10,   125,   125,     8,     8,     8,     8,  1620,  1620,
  401.   1620,    42,  1620,   981,  1657,-32768,-32768,    -7,  1402,    -7,
  402. -32768,-32768,-32768,-32768,   100,-32768,    10,  1715,  1131,-32768,
  403.     96,    39,  1538,   205,   117,-32768,   758,-32768,    -6,-32768,
  404. -32768,-32768,-32768,     7,   205,-32768,-32768,-32768,  1402,-32768,
  405.    166,-32768,  1402,   100,    -6,  1620,-32768,  1402,  1250,    -7,
  406.   1131,-32768,  1250,   151,   -12,   100,-32768,-32768,    -6,     3,
  407. -32768,    37,  1620,  1620,  1620,    -7,  1678,  1201,  1678,  1678,
  408.    181,  1678,  1678,  1678,   205,-32768,-32768,-32768,-32768,-32768,
  409.     99,    56,-32768,-32768,-32768,  1402,    -6,-32768,    11,    -6,
  410.    131,   183,  1061,-32768,-32768,    96,  1402,  1402,  1402,-32768,
  411.   1538,-32768,  1538,   635,    83,-32768,  1599,  1579,  1474,  1678,
  412.     -6,-32768,   103,   981,    -7,   981,  1620,    99,   623,  1620,
  413.     -7,  1678,  1538,-32768,-32768,-32768,   170,-32768,-32768,  1250,
  414.     -6,  1620,    99,-32768,  1538,    -6,    -6,   981,    99,    -6,
  415.    981,-32768,-32768,    -6,   981,-32768,   981,-32768,-32768,   190,
  416.    191,-32768
  417. };
  418.  
  419. static const short yypgoto[] = {-32768,
  420. -32768,   167,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  421.    211,-32768,   107,   -53,   315,  -105,-32768,-32768,-32768,   199,
  422.     97,   -22,   -62,-32768,-32768,  -103,-32768,-32768,    94,   -14,
  423.     -3,-32768,  -202,-32768,   318,   177,  -134,    95,   124,   -69,
  424.    407,  -138,   420,  -177
  425. };
  426.  
  427.  
  428. #define    YYLAST        1790
  429.  
  430.  
  431. static const short yytable[] = {    31,
  432.    142,   170,   174,   205,   228,     1,     1,   239,    63,   135,
  433.    240,   135,     4,     7,    36,    90,   141,   207,    37,    64,
  434.    252,    31,   119,    50,   261,   263,   264,   265,    51,   267,
  435.    268,   269,   118,   118,    24,   174,   219,   135,   175,   227,
  436.     91,    92,   220,   188,    37,   129,   118,   118,   -83,   133,
  437.    136,   -83,   136,    38,     1,   135,   272,   210,   214,   187,
  438.     89,   216,   -73,    22,   273,   244,   193,   283,   275,   143,
  439.    144,   204,   146,   147,   148,   149,   150,   151,   136,   295,
  440.    136,   174,   -83,   -83,     1,   134,     7,   123,   124,     8,
  441.      9,   229,   137,   145,-32768,   152,   136,   136,   211,   -83,
  442.    169,   169,    38,   285,   160,   223,   286,    47,    48,    49,
  443.    -91,   -74,    55,    55,   162,    55,    61,   237,    14,    15,
  444.     65,    68,   125,   126,   163,    55,    35,   236,    18,    19,
  445.     24,   199,    38,    52,    71,   203,    22,    53,   121,   224,
  446.    225,    91,    92,   131,   132,   120,    55,   165,    35,   122,
  447.     70,    35,    91,    92,   137,   208,   209,   169,    55,   213,
  448.     38,   169,    35,   194,   222,   201,    35,   198,   287,   243,
  449.    289,   251,    86,    87,    88,    64,   293,    89,    55,    55,
  450.     55,    55,    55,    55,   266,   277,   278,   296,   299,   311,
  451.    312,    67,   303,   281,   164,   306,   249,   255,    60,   308,
  452.      0,   309,   246,   172,   185,     0,    55,   118,    41,    41,
  453.      0,   191,    55,     0,     0,     0,     0,     0,     0,   257,
  454.    258,   259,     0,    55,     0,     0,    41,    55,     0,     0,
  455.      0,    58,   200,     0,     0,     0,     0,    55,    55,     0,
  456.     55,    55,    55,    55,    55,    55,    47,     0,     0,   279,
  457.     84,    85,    86,    87,    88,     0,     0,    89,     0,     0,
  458.      0,     0,     0,    55,     0,     0,     0,     0,     0,     0,
  459.      0,    47,    55,   290,     0,     0,   169,    55,     0,     0,
  460.      0,     0,     0,     0,     0,   238,     0,     0,   169,     0,
  461.      0,     0,     0,    55,     0,     0,     0,    55,    41,    41,
  462.      0,   245,    55,    55,    41,     0,     0,    55,     0,     0,
  463.     41,     0,     0,     0,     0,   254,     0,     0,     0,     0,
  464.    180,   185,   185,   185,   185,    44,   185,   185,   185,     0,
  465.      0,     0,     0,     0,     0,    54,    56,     0,    59,     0,
  466.     55,     0,    72,   274,     0,     0,   276,     0,    83,     0,
  467.      0,    55,    55,    55,     0,    55,     0,    55,    55,    55,
  468.     41,    55,    55,    55,   185,     0,    41,   284,    41,    59,
  469.      0,     0,     0,    55,     0,     0,   185,    55,     0,     0,
  470.      0,    83,     0,     0,    55,     0,     0,   298,   221,    55,
  471.      0,     0,   301,   302,     0,     0,   305,     0,     0,     0,
  472.    307,   153,   154,   155,   156,   157,   158,     0,    41,     0,
  473.      0,     0,     0,     0,   166,   167,     0,     0,     0,     0,
  474.    171,     0,     0,     0,    41,     0,   186,   184,     0,    83,
  475.      0,     0,     0,     0,     0,    83,     0,   180,   180,   180,
  476.    180,     0,   180,   180,   180,     0,   195,     0,     0,     0,
  477.     83,     0,     0,     0,   115,     0,     0,     0,     0,     0,
  478.     83,    83,     0,    83,    83,    83,    83,    83,    83,   138,
  479.      0,     0,     0,    41,     0,     0,   212,     0,     0,    41,
  480.    180,     0,   217,     0,   218,     0,    83,     0,     0,   115,
  481.      0,     0,   180,     0,     0,    59,     0,     0,     0,     0,
  482.    235,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  483.      0,     0,     0,     0,     0,     0,    83,     0,     0,     0,
  484.     83,     0,   192,     0,   248,    83,    83,   115,     0,     0,
  485.     83,     0,   115,   190,     0,     0,     0,   196,   197,     0,
  486.    260,     0,     0,     0,   184,   184,   184,   184,     0,   184,
  487.    184,   184,     0,     0,     0,     0,     0,     0,     0,     0,
  488.    115,   190,     0,    83,     0,     0,     0,     0,     0,     0,
  489.      0,     0,     0,     0,    83,    83,    83,     0,   235,     0,
  490.    235,   235,   235,   115,   235,   235,   235,   184,     0,   288,
  491.      0,     0,     0,     0,   190,   294,    83,     0,     0,   184,
  492.    235,     0,     0,     0,     0,     0,   115,    83,     0,     0,
  493.      0,     0,   235,     0,     0,   247,     0,     0,     0,   250,
  494.      0,     0,     0,   190,     0,     6,     7,     0,   256,     8,
  495.      9,    73,     0,     0,    74,   253,     0,     0,     7,     0,
  496.      0,     8,     9,-32768,     0,     0,     0,   271,     0,     0,
  497.      0,     0,     0,     0,     0,    75,    76,    77,    14,    15,
  498.     16,    17,    78,     0,     0,    80,    81,    82,    18,    19,
  499.     14,    15,   280,    52,     0,     0,    22,    53,     0,     0,
  500.     18,    19,     0,    38,   291,    52,     0,     0,    22,    53,
  501.      0,     0,     0,   115,     0,   115,   297,     0,   292,   300,
  502.      0,     0,     0,     0,     0,   304,     0,     0,     0,    93,
  503.      0,     6,     7,     0,     0,     8,     9,   115,     0,     0,
  504.    115,     0,     0,     0,   115,    94,   115,    95,    96,    97,
  505.     98,    99,   100,   101,   102,   103,   104,   105,     0,    13,
  506.    106,     0,     0,     0,    14,    15,    16,    17,     0,     0,
  507.      0,     0,     0,     0,    18,    19,     0,    20,   173,    21,
  508.      6,     7,    22,    23,     8,     9,     0,    24,   107,    38,
  509.      0,     0,     0,     0,    94,     0,    95,    96,    97,    98,
  510.     99,   100,   101,   102,   103,   104,   105,     0,    13,   106,
  511.      0,     0,     0,    14,    15,    16,    17,     7,     0,     0,
  512.      8,     9,    73,    18,    19,-32768,    20,     0,    21,     0,
  513.      0,    22,    23,     0,     0,     0,    24,   107,    38,   176,
  514.      0,     6,     7,     0,     0,     8,     9,     0,   -82,    14,
  515.     15,   -82,     0,     0,     0,     0,    80,    81,    82,    18,
  516.     19,     0,     0,     0,    52,     0,     0,    22,    53,   177,
  517.      0,     0,     0,     0,    14,    15,    16,    17,     0,     0,
  518.      0,     0,   -82,   -82,    18,    19,     0,    20,     0,   178,
  519.      0,     0,    22,   179,    -6,     5,     0,     6,     7,   -82,
  520.      0,     8,     9,     0,     0,     0,     0,    -6,     0,    10,
  521.     11,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  522.      0,     0,     0,     0,    12,    13,     0,     0,     0,     0,
  523.     14,    15,    16,    17,     0,     0,     0,     0,     0,     0,
  524.     18,    19,     0,    20,     0,    21,     0,     0,    22,    23,
  525.      0,   -65,    66,    24,     6,     7,     0,     0,     8,     9,
  526.      0,     0,     0,     0,     1,     0,    10,    11,     0,     0,
  527.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  528.      0,    12,    13,     0,     0,     0,     0,    14,    15,    16,
  529.     17,     0,     0,     0,     0,     0,     0,    18,    19,     0,
  530.     20,     0,    21,     6,     7,    22,    23,     8,     9,     0,
  531.     24,     0,     0,     0,     0,     0,     0,    94,     0,    95,
  532.     96,    97,    98,    99,   100,   101,   102,   103,   104,   105,
  533.      0,    13,   106,     0,     0,     0,    14,    15,    16,    17,
  534.      0,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  535.      0,    21,     0,     0,    22,    23,     0,     0,     0,    24,
  536.      0,    38,     6,     7,     0,     0,     8,     9,    73,     0,
  537.      0,    74,     1,     0,     0,     0,     0,     0,     0,     0,
  538.      0,     0,     0,     6,     7,     0,     0,     8,     9,     0,
  539.      0,     0,    75,    76,    77,    14,    15,    16,    17,    78,
  540.      0,     0,    80,    81,    82,    18,    19,     0,     0,     0,
  541.     52,    13,     0,    22,    53,     0,    14,    15,    16,    17,
  542.     38,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  543.     62,    21,     6,     7,    22,    23,     8,     9,     0,     0,
  544.      0,    38,     0,     0,     0,     0,     0,     0,     0,     0,
  545.      0,    62,     0,     6,     7,     0,     0,     8,     9,     0,
  546.     13,     0,     0,     0,     0,    14,    15,    16,    17,     0,
  547.      0,     0,     0,     0,     0,    18,    19,     0,    20,     0,
  548.     21,    13,     0,    22,    23,   -90,    14,    15,    16,    17,
  549.      0,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  550.    202,    21,     6,     7,    22,    23,     8,     9,     0,     0,
  551.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  552.      0,   262,     0,     6,     7,     0,     0,     8,     9,     0,
  553.     13,     0,     0,     0,     0,    14,    15,    16,    17,     0,
  554.      0,     0,     0,     0,     0,    18,    19,     0,    20,     0,
  555.     21,   177,     0,    22,    23,     0,    14,    15,    16,    17,
  556.      0,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  557.      0,   178,     6,     7,    22,    53,     8,     9,    73,     0,
  558.      0,    74,     0,     0,     0,     0,     0,     0,     0,     0,
  559.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  560.      0,     0,    75,    76,    77,    14,    15,    16,    17,    78,
  561.      0,     0,    80,    81,    82,    18,    19,     0,     0,     0,
  562.     52,     0,     0,    22,    53,   137,     6,     7,     0,     0,
  563.      8,     9,    73,     0,     0,    74,     0,     0,     0,     0,
  564.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  565.      7,     0,     0,     8,     9,-32768,    75,    76,    77,    14,
  566.     15,    16,    17,    78,     0,    79,    80,    81,    82,    18,
  567.     19,     0,     0,     0,    52,     6,     7,    22,    53,     8,
  568.      9,    73,    14,    15,    74,     0,     0,     0,     0,-32768,
  569. -32768,-32768,    18,    19,     0,     0,     0,    52,     0,     0,
  570.     22,    53,     0,     0,     0,    75,    76,    77,    14,    15,
  571.     16,    17,    78,   206,     0,    80,    81,    82,    18,    19,
  572.      0,     0,     0,    52,     6,     7,    22,    53,     8,     9,
  573.     73,     0,     0,    74,     0,     0,     0,     0,     0,     0,
  574.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  575.      0,     0,     0,     0,    75,    76,    77,    14,    15,    16,
  576.     17,    78,     0,     0,    80,    81,    82,    18,    19,     0,
  577.      0,     0,    52,     6,     7,    22,    53,     8,     9,    73,
  578.      0,     0,    74,     0,     0,     0,     0,     0,     0,     0,
  579.      0,     0,     0,     0,     0,     0,     6,     7,     0,     0,
  580.      8,     9,   229,    75,    76,   230,    14,    15,    16,    17,
  581.      0,     0,     0,    80,    81,    82,    18,    19,     0,     0,
  582.      0,    52,     0,     0,    22,    53,   231,   232,   233,    14,
  583.     15,    16,    17,   234,   282,     0,     0,     6,     7,    18,
  584.     19,     8,     9,    73,    52,     0,    74,    22,    53,     0,
  585.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  586.      6,     7,     0,     0,     8,     9,   229,    75,     0,   230,
  587.     14,    15,    16,    17,     0,     0,     0,    80,    81,    82,
  588.     18,    19,     0,     0,     0,    52,     0,     0,    22,    53,
  589.    231,   232,   233,    14,    15,    16,    17,   234,     0,     0,
  590.      0,     6,     7,    18,    19,     8,     9,   229,    52,     0,
  591.    230,    22,    53,     0,     0,     0,     0,     0,     0,     0,
  592.      0,     6,     7,     0,     0,     8,     9,   229,     0,     0,
  593.    230,   231,   232,     0,    14,    15,    16,    17,     0,     0,
  594.      0,     0,     6,     7,    18,    19,     8,     9,     0,    52,
  595.      0,   231,    22,    53,    14,    15,    16,    17,     0,     0,
  596.      0,     0,     0,     0,    18,    19,     0,     0,     0,    52,
  597.     13,     0,    22,    53,     0,    14,    15,    16,    17,     6,
  598.    215,     0,     0,     8,     9,    18,    19,     0,    20,     0,
  599.     21,     0,     0,    22,    23,     0,     0,     0,     0,     0,
  600.      6,     7,     0,     0,     8,     9,     0,    13,     0,     0,
  601.      0,     0,    14,    15,    16,    17,     0,     0,     0,     0,
  602.      0,     0,    18,    19,     0,    20,     0,    21,   177,     0,
  603.     22,    23,     0,    14,    15,    16,    17,     6,     7,     0,
  604.      0,     8,     9,    18,    19,     0,    20,     0,   178,     0,
  605.      0,    22,    53,     0,     0,     0,     0,     6,     7,     0,
  606.      0,     8,     9,     0,     0,     0,     0,     0,     0,     0,
  607.     14,    15,    16,    17,     0,     0,     0,     0,     0,     0,
  608.     18,    19,     0,    20,     0,    52,     0,     0,    22,    53,
  609.     14,    15,    16,    17,     0,     0,     0,     0,     0,     0,
  610.     18,    19,     0,     0,     0,    52,     0,     0,    22,    53
  611. };
  612.  
  613. static const short yycheck[] = {     3,
  614.     70,   105,   108,   142,   182,    13,    13,     1,    23,     1,
  615.      4,     1,    13,     4,    55,    11,    70,   152,    57,    23,
  616.     33,    25,    37,    55,   227,   228,   229,   230,    55,   232,
  617.    233,   234,    36,    37,    59,   141,   175,     1,   108,     1,
  618.     36,    37,   177,   113,    57,    43,    50,    51,    10,    53,
  619.     42,    13,    42,    61,    13,     1,     1,   161,   164,   113,
  620.     53,   165,    56,    54,   242,   204,    58,   270,    58,    73,
  621.     74,   141,    76,    77,    78,    79,    80,    81,    42,   282,
  622.     42,   187,    44,    45,    13,     5,     4,     3,     4,     7,
  623.      8,     9,    56,     4,    12,    31,    42,    42,    57,    61,
  624.    104,   105,    61,     1,    55,    10,     4,    13,    14,    15,
  625.     56,    56,    18,    19,     4,    21,    22,   187,    36,    37,
  626.     24,    25,    38,    39,    55,    31,     3,    11,    46,    47,
  627.     59,   135,    61,    51,    28,   139,    54,    55,    42,    44,
  628.     45,    36,    37,    50,    51,    39,    52,    55,    25,    43,
  629.     27,    28,    36,    37,    56,   159,   160,   161,    64,   163,
  630.     61,   165,    39,    55,   179,    33,    43,    49,   274,     4,
  631.    276,    21,    48,    49,    50,   179,   280,    53,    84,    85,
  632.     86,    87,    88,    89,     4,    55,     4,    18,   292,     0,
  633.      0,    25,   298,   256,    98,   301,   211,   220,    22,   305,
  634.     -1,   307,   206,   107,   110,    -1,   112,   211,    10,    11,
  635.     -1,   115,   118,    -1,    -1,    -1,    -1,    -1,    -1,   223,
  636.    224,   225,    -1,   129,    -1,    -1,    28,   133,    -1,    -1,
  637.     -1,    21,   136,    -1,    -1,    -1,    -1,   143,   144,    -1,
  638.    146,   147,   148,   149,   150,   151,   152,    -1,    -1,   253,
  639.     46,    47,    48,    49,    50,    -1,    -1,    53,    -1,    -1,
  640.     -1,    -1,    -1,   169,    -1,    -1,    -1,    -1,    -1,    -1,
  641.     -1,   177,   178,   277,    -1,    -1,   280,   183,    -1,    -1,
  642.     -1,    -1,    -1,    -1,    -1,   189,    -1,    -1,   292,    -1,
  643.     -1,    -1,    -1,   199,    -1,    -1,    -1,   203,   100,   101,
  644.     -1,   205,   208,   209,   106,    -1,    -1,   213,    -1,    -1,
  645.    112,    -1,    -1,    -1,    -1,   219,    -1,    -1,    -1,    -1,
  646.    110,   227,   228,   229,   230,    11,   232,   233,   234,    -1,
  647.     -1,    -1,    -1,    -1,    -1,    18,    19,    -1,    21,    -1,
  648.    246,    -1,    28,   247,    -1,    -1,   250,    -1,    31,    -1,
  649.     -1,   257,   258,   259,    -1,   261,    -1,   263,   264,   265,
  650.    162,   267,   268,   269,   270,    -1,   168,   271,   170,    52,
  651.     -1,    -1,    -1,   279,    -1,    -1,   282,   283,    -1,    -1,
  652.     -1,    64,    -1,    -1,   290,    -1,    -1,   291,   178,   295,
  653.     -1,    -1,   296,   297,    -1,    -1,   300,    -1,    -1,    -1,
  654.    304,    84,    85,    86,    87,    88,    89,    -1,   210,    -1,
  655.     -1,    -1,    -1,    -1,   100,   101,    -1,    -1,    -1,    -1,
  656.    106,    -1,    -1,    -1,   226,    -1,   112,   110,    -1,   112,
  657.     -1,    -1,    -1,    -1,    -1,   118,    -1,   227,   228,   229,
  658.    230,    -1,   232,   233,   234,    -1,   129,    -1,    -1,    -1,
  659.    133,    -1,    -1,    -1,    35,    -1,    -1,    -1,    -1,    -1,
  660.    143,   144,    -1,   146,   147,   148,   149,   150,   151,    63,
  661.     -1,    -1,    -1,   275,    -1,    -1,   162,    -1,    -1,   281,
  662.    270,    -1,   168,    -1,   170,    -1,   169,    -1,    -1,    70,
  663.     -1,    -1,   282,    -1,    -1,   178,    -1,    -1,    -1,    -1,
  664.    183,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  665.     -1,    -1,    -1,    -1,    -1,    -1,   199,    -1,    -1,    -1,
  666.    203,    -1,   116,    -1,   210,   208,   209,   108,    -1,    -1,
  667.    213,    -1,   113,   114,    -1,    -1,    -1,   131,   132,    -1,
  668.    226,    -1,    -1,    -1,   227,   228,   229,   230,    -1,   232,
  669.    233,   234,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  670.    141,   142,    -1,   246,    -1,    -1,    -1,    -1,    -1,    -1,
  671.     -1,    -1,    -1,    -1,   257,   258,   259,    -1,   261,    -1,
  672.    263,   264,   265,   164,   267,   268,   269,   270,    -1,   275,
  673.     -1,    -1,    -1,    -1,   175,   281,   279,    -1,    -1,   282,
  674.    283,    -1,    -1,    -1,    -1,    -1,   187,   290,    -1,    -1,
  675.     -1,    -1,   295,    -1,    -1,   209,    -1,    -1,    -1,   213,
  676.     -1,    -1,    -1,   204,    -1,     3,     4,    -1,   222,     7,
  677.      8,     9,    -1,    -1,    12,   216,    -1,    -1,     4,    -1,
  678.     -1,     7,     8,     9,    -1,    -1,    -1,   241,    -1,    -1,
  679.     -1,    -1,    -1,    -1,    -1,    33,    34,    35,    36,    37,
  680.     38,    39,    40,    -1,    -1,    43,    44,    45,    46,    47,
  681.     36,    37,   253,    51,    -1,    -1,    54,    55,    -1,    -1,
  682.     46,    47,    -1,    61,   278,    51,    -1,    -1,    54,    55,
  683.     -1,    -1,    -1,   274,    -1,   276,   290,    -1,   279,   293,
  684.     -1,    -1,    -1,    -1,    -1,   299,    -1,    -1,    -1,     1,
  685.     -1,     3,     4,    -1,    -1,     7,     8,   298,    -1,    -1,
  686.    301,    -1,    -1,    -1,   305,    17,   307,    19,    20,    21,
  687.     22,    23,    24,    25,    26,    27,    28,    29,    -1,    31,
  688.     32,    -1,    -1,    -1,    36,    37,    38,    39,    -1,    -1,
  689.     -1,    -1,    -1,    -1,    46,    47,    -1,    49,     1,    51,
  690.      3,     4,    54,    55,     7,     8,    -1,    59,    60,    61,
  691.     -1,    -1,    -1,    -1,    17,    -1,    19,    20,    21,    22,
  692.     23,    24,    25,    26,    27,    28,    29,    -1,    31,    32,
  693.     -1,    -1,    -1,    36,    37,    38,    39,     4,    -1,    -1,
  694.      7,     8,     9,    46,    47,    12,    49,    -1,    51,    -1,
  695.     -1,    54,    55,    -1,    -1,    -1,    59,    60,    61,     1,
  696.     -1,     3,     4,    -1,    -1,     7,     8,    -1,    10,    36,
  697.     37,    13,    -1,    -1,    -1,    -1,    43,    44,    45,    46,
  698.     47,    -1,    -1,    -1,    51,    -1,    -1,    54,    55,    31,
  699.     -1,    -1,    -1,    -1,    36,    37,    38,    39,    -1,    -1,
  700.     -1,    -1,    44,    45,    46,    47,    -1,    49,    -1,    51,
  701.     -1,    -1,    54,    55,     0,     1,    -1,     3,     4,    61,
  702.     -1,     7,     8,    -1,    -1,    -1,    -1,    13,    -1,    15,
  703.     16,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  704.     -1,    -1,    -1,    -1,    30,    31,    -1,    -1,    -1,    -1,
  705.     36,    37,    38,    39,    -1,    -1,    -1,    -1,    -1,    -1,
  706.     46,    47,    -1,    49,    -1,    51,    -1,    -1,    54,    55,
  707.     -1,     0,     1,    59,     3,     4,    -1,    -1,     7,     8,
  708.     -1,    -1,    -1,    -1,    13,    -1,    15,    16,    -1,    -1,
  709.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  710.     -1,    30,    31,    -1,    -1,    -1,    -1,    36,    37,    38,
  711.     39,    -1,    -1,    -1,    -1,    -1,    -1,    46,    47,    -1,
  712.     49,    -1,    51,     3,     4,    54,    55,     7,     8,    -1,
  713.     59,    -1,    -1,    -1,    -1,    -1,    -1,    17,    -1,    19,
  714.     20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
  715.     -1,    31,    32,    -1,    -1,    -1,    36,    37,    38,    39,
  716.     -1,    -1,    -1,    -1,    -1,    -1,    46,    47,    -1,    49,
  717.     -1,    51,    -1,    -1,    54,    55,    -1,    -1,    -1,    59,
  718.     -1,    61,     3,     4,    -1,    -1,     7,     8,     9,    -1,
  719.     -1,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  720.     -1,    -1,    -1,     3,     4,    -1,    -1,     7,     8,    -1,
  721.     -1,    -1,    33,    34,    35,    36,    37,    38,    39,    40,
  722.     -1,    -1,    43,    44,    45,    46,    47,    -1,    -1,    -1,
  723.     51,    31,    -1,    54,    55,    -1,    36,    37,    38,    39,
  724.     61,    -1,    -1,    -1,    -1,    -1,    46,    47,    -1,    49,
  725.      1,    51,     3,     4,    54,    55,     7,     8,    -1,    -1,
  726.     -1,    61,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  727.     -1,     1,    -1,     3,     4,    -1,    -1,     7,     8,    -1,
  728.     31,    -1,    -1,    -1,    -1,    36,    37,    38,    39,    -1,
  729.     -1,    -1,    -1,    -1,    -1,    46,    47,    -1,    49,    -1,
  730.     51,    31,    -1,    54,    55,    56,    36,    37,    38,    39,
  731.     -1,    -1,    -1,    -1,    -1,    -1,    46,    47,    -1,    49,
  732.      1,    51,     3,     4,    54,    55,     7,     8,    -1,    -1,
  733.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  734.     -1,     1,    -1,     3,     4,    -1,    -1,     7,     8,    -1,
  735.     31,    -1,    -1,    -1,    -1,    36,    37,    38,    39,    -1,
  736.     -1,    -1,    -1,    -1,    -1,    46,    47,    -1,    49,    -1,
  737.     51,    31,    -1,    54,    55,    -1,    36,    37,    38,    39,
  738.     -1,    -1,    -1,    -1,    -1,    -1,    46,    47,    -1,    49,
  739.     -1,    51,     3,     4,    54,    55,     7,     8,     9,    -1,
  740.     -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  741.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  742.     -1,    -1,    33,    34,    35,    36,    37,    38,    39,    40,
  743.     -1,    -1,    43,    44,    45,    46,    47,    -1,    -1,    -1,
  744.     51,    -1,    -1,    54,    55,    56,     3,     4,    -1,    -1,
  745.      7,     8,     9,    -1,    -1,    12,    -1,    -1,    -1,    -1,
  746.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  747.      4,    -1,    -1,     7,     8,     9,    33,    34,    35,    36,
  748.     37,    38,    39,    40,    -1,    42,    43,    44,    45,    46,
  749.     47,    -1,    -1,    -1,    51,     3,     4,    54,    55,     7,
  750.      8,     9,    36,    37,    12,    -1,    -1,    -1,    -1,    43,
  751.     44,    45,    46,    47,    -1,    -1,    -1,    51,    -1,    -1,
  752.     54,    55,    -1,    -1,    -1,    33,    34,    35,    36,    37,
  753.     38,    39,    40,    41,    -1,    43,    44,    45,    46,    47,
  754.     -1,    -1,    -1,    51,     3,     4,    54,    55,     7,     8,
  755.      9,    -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,
  756.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  757.     -1,    -1,    -1,    -1,    33,    34,    35,    36,    37,    38,
  758.     39,    40,    -1,    -1,    43,    44,    45,    46,    47,    -1,
  759.     -1,    -1,    51,     3,     4,    54,    55,     7,     8,     9,
  760.     -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  761.     -1,    -1,    -1,    -1,    -1,    -1,     3,     4,    -1,    -1,
  762.      7,     8,     9,    33,    34,    12,    36,    37,    38,    39,
  763.     -1,    -1,    -1,    43,    44,    45,    46,    47,    -1,    -1,
  764.     -1,    51,    -1,    -1,    54,    55,    33,    34,    35,    36,
  765.     37,    38,    39,    40,    41,    -1,    -1,     3,     4,    46,
  766.     47,     7,     8,     9,    51,    -1,    12,    54,    55,    -1,
  767.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  768.      3,     4,    -1,    -1,     7,     8,     9,    33,    -1,    12,
  769.     36,    37,    38,    39,    -1,    -1,    -1,    43,    44,    45,
  770.     46,    47,    -1,    -1,    -1,    51,    -1,    -1,    54,    55,
  771.     33,    34,    35,    36,    37,    38,    39,    40,    -1,    -1,
  772.     -1,     3,     4,    46,    47,     7,     8,     9,    51,    -1,
  773.     12,    54,    55,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  774.     -1,     3,     4,    -1,    -1,     7,     8,     9,    -1,    -1,
  775.     12,    33,    34,    -1,    36,    37,    38,    39,    -1,    -1,
  776.     -1,    -1,     3,     4,    46,    47,     7,     8,    -1,    51,
  777.     -1,    33,    54,    55,    36,    37,    38,    39,    -1,    -1,
  778.     -1,    -1,    -1,    -1,    46,    47,    -1,    -1,    -1,    51,
  779.     31,    -1,    54,    55,    -1,    36,    37,    38,    39,     3,
  780.      4,    -1,    -1,     7,     8,    46,    47,    -1,    49,    -1,
  781.     51,    -1,    -1,    54,    55,    -1,    -1,    -1,    -1,    -1,
  782.      3,     4,    -1,    -1,     7,     8,    -1,    31,    -1,    -1,
  783.     -1,    -1,    36,    37,    38,    39,    -1,    -1,    -1,    -1,
  784.     -1,    -1,    46,    47,    -1,    49,    -1,    51,    31,    -1,
  785.     54,    55,    -1,    36,    37,    38,    39,     3,     4,    -1,
  786.     -1,     7,     8,    46,    47,    -1,    49,    -1,    51,    -1,
  787.     -1,    54,    55,    -1,    -1,    -1,    -1,     3,     4,    -1,
  788.     -1,     7,     8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  789.     36,    37,    38,    39,    -1,    -1,    -1,    -1,    -1,    -1,
  790.     46,    47,    -1,    49,    -1,    51,    -1,    -1,    54,    55,
  791.     36,    37,    38,    39,    -1,    -1,    -1,    -1,    -1,    -1,
  792.     46,    47,    -1,    -1,    -1,    51,    -1,    -1,    54,    55
  793. };
  794. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  795. #line 3 "/usr/local/lib/bison.simple"
  796.  
  797. /* Skeleton output parser for bison,
  798.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  799.  
  800.    This program is free software; you can redistribute it and/or modify
  801.    it under the terms of the GNU General Public License as published by
  802.    the Free Software Foundation; either version 1, or (at your option)
  803.    any later version.
  804.  
  805.    This program is distributed in the hope that it will be useful,
  806.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  807.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  808.    GNU General Public License for more details.
  809.  
  810.    You should have received a copy of the GNU General Public License
  811.    along with this program; if not, write to the Free Software
  812.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  813.  
  814.  
  815. #ifndef alloca
  816. #ifdef __GNUC__
  817. #define alloca __builtin_alloca
  818. #else /* not GNU C.  */
  819. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  820. #include <alloca.h>
  821. #else /* not sparc */
  822. #if defined (MSDOS) && !defined (__TURBOC__)
  823. #include <malloc.h>
  824. #else /* not MSDOS, or __TURBOC__ */
  825. #if defined(_AIX)
  826. #include <malloc.h>
  827.  #pragma alloca
  828. #else /* not MSDOS, __TURBOC__, or _AIX */
  829. #ifdef __hpux
  830. #ifdef __cplusplus
  831. extern "C" {
  832. void *alloca (unsigned int);
  833. };
  834. #else /* not __cplusplus */
  835. void *alloca ();
  836. #endif /* not __cplusplus */
  837. #endif /* __hpux */
  838. #endif /* not _AIX */
  839. #endif /* not MSDOS, or __TURBOC__ */
  840. #endif /* not sparc.  */
  841. #endif /* not GNU C.  */
  842. #endif /* alloca not defined.  */
  843.  
  844. /* This is the parser code that is written into each bison parser
  845.   when the %semantic_parser declaration is not specified in the grammar.
  846.   It was written by Richard Stallman by simplifying the hairy parser
  847.   used when %semantic_parser is specified.  */
  848.  
  849. /* Note: there must be only one dollar sign in this file.
  850.    It is replaced by the list of actions, each action
  851.    as one case of the switch.  */
  852.  
  853. #define yyerrok        (yyerrstatus = 0)
  854. #define yyclearin    (yychar = YYEMPTY)
  855. #define YYEMPTY        -2
  856. #define YYEOF        0
  857. #define YYACCEPT    return(0)
  858. #define YYABORT     return(1)
  859. #define YYERROR        goto yyerrlab1
  860. /* Like YYERROR except do call yyerror.
  861.    This remains here temporarily to ease the
  862.    transition to the new meaning of YYERROR, for GCC.
  863.    Once GCC version 2 has supplanted version 1, this can go.  */
  864. #define YYFAIL        goto yyerrlab
  865. #define YYRECOVERING()  (!!yyerrstatus)
  866. #define YYBACKUP(token, value) \
  867. do                                \
  868.   if (yychar == YYEMPTY && yylen == 1)                \
  869.     { yychar = (token), yylval = (value);            \
  870.       yychar1 = YYTRANSLATE (yychar);                \
  871.       YYPOPSTACK;                        \
  872.       goto yybackup;                        \
  873.     }                                \
  874.   else                                \
  875.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  876. while (0)
  877.  
  878. #define YYTERROR    1
  879. #define YYERRCODE    256
  880.  
  881. #ifndef YYPURE
  882. #define YYLEX        yylex()
  883. #endif
  884.  
  885. #ifdef YYPURE
  886. #ifdef YYLSP_NEEDED
  887. #define YYLEX        yylex(&yylval, &yylloc)
  888. #else
  889. #define YYLEX        yylex(&yylval)
  890. #endif
  891. #endif
  892.  
  893. /* If nonreentrant, generate the variables here */
  894.  
  895. #ifndef YYPURE
  896.  
  897. int    yychar;            /*  the lookahead symbol        */
  898. YYSTYPE    yylval;            /*  the semantic value of the        */
  899.                 /*  lookahead symbol            */
  900.  
  901. #ifdef YYLSP_NEEDED
  902. YYLTYPE yylloc;            /*  location data for the lookahead    */
  903.                 /*  symbol                */
  904. #endif
  905.  
  906. int yynerrs;            /*  number of parse errors so far       */
  907. #endif  /* not YYPURE */
  908.  
  909. #if YYDEBUG != 0
  910. int yydebug;            /*  nonzero means print parse trace    */
  911. /* Since this is uninitialized, it does not stop multiple parsers
  912.    from coexisting.  */
  913. #endif
  914.  
  915. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  916.  
  917. #ifndef    YYINITDEPTH
  918. #define YYINITDEPTH 200
  919. #endif
  920.  
  921. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  922.     (effective only if the built-in stack extension method is used).  */
  923.  
  924. #if YYMAXDEPTH == 0
  925. #undef YYMAXDEPTH
  926. #endif
  927.  
  928. #ifndef YYMAXDEPTH
  929. #define YYMAXDEPTH 10000
  930. #endif
  931.  
  932. /* Prevent warning if -Wstrict-prototypes.  */
  933. #ifdef __GNUC__
  934. int yyparse (void);
  935. #endif
  936.  
  937. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  938. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  939. #else                /* not GNU C or C++ */
  940. #ifndef __cplusplus
  941.  
  942. /* This is the most reliable way to avoid incompatibilities
  943.    in available built-in functions on various systems.  */
  944. static void
  945. __yy_bcopy (from, to, count)
  946.      char *from;
  947.      char *to;
  948.      int count;
  949. {
  950.   register char *f = from;
  951.   register char *t = to;
  952.   register int i = count;
  953.  
  954.   while (i-- > 0)
  955.     *t++ = *f++;
  956. }
  957.  
  958. #else /* __cplusplus */
  959.  
  960. /* This is the most reliable way to avoid incompatibilities
  961.    in available built-in functions on various systems.  */
  962. static void
  963. __yy_bcopy (char *from, char *to, int count)
  964. {
  965.   register char *f = from;
  966.   register char *t = to;
  967.   register int i = count;
  968.  
  969.   while (i-- > 0)
  970.     *t++ = *f++;
  971. }
  972.  
  973. #endif
  974. #endif
  975.  
  976. #line 184 "/usr/local/lib/bison.simple"
  977. int
  978. yyparse()
  979. {
  980.   register int yystate;
  981.   register int yyn;
  982.   register short *yyssp;
  983.   register YYSTYPE *yyvsp;
  984.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  985.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  986.  
  987.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  988.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  989.  
  990.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  991.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  992.  
  993. #ifdef YYLSP_NEEDED
  994.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  995.   YYLTYPE *yyls = yylsa;
  996.   YYLTYPE *yylsp;
  997.  
  998. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  999. #else
  1000. #define YYPOPSTACK   (yyvsp--, yyssp--)
  1001. #endif
  1002.  
  1003.   int yystacksize = YYINITDEPTH;
  1004.  
  1005. #ifdef YYPURE
  1006.   int yychar;
  1007.   YYSTYPE yylval;
  1008.   int yynerrs;
  1009. #ifdef YYLSP_NEEDED
  1010.   YYLTYPE yylloc;
  1011. #endif
  1012. #endif
  1013.  
  1014.   YYSTYPE yyval;        /*  the variable used to return        */
  1015.                 /*  semantic values from the action    */
  1016.                 /*  routines                */
  1017.  
  1018.   int yylen;
  1019.  
  1020. #if YYDEBUG != 0
  1021.   if (yydebug)
  1022.     fprintf(stderr, "Starting parse\n");
  1023. #endif
  1024.  
  1025.   yystate = 0;
  1026.   yyerrstatus = 0;
  1027.   yynerrs = 0;
  1028.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  1029.  
  1030.   /* Initialize stack pointers.
  1031.      Waste one element of value and location stack
  1032.      so that they stay on the same level as the state stack.
  1033.      The wasted elements are never initialized.  */
  1034.  
  1035.   yyssp = yyss - 1;
  1036.   yyvsp = yyvs;
  1037. #ifdef YYLSP_NEEDED
  1038.   yylsp = yyls;
  1039. #endif
  1040.  
  1041. /* Push a new state, which is found in  yystate  .  */
  1042. /* In all cases, when you get here, the value and location stacks
  1043.    have just been pushed. so pushing a state here evens the stacks.  */
  1044. yynewstate:
  1045.  
  1046.   *++yyssp = yystate;
  1047.  
  1048.   if (yyssp >= yyss + yystacksize - 1)
  1049.     {
  1050.       /* Give user a chance to reallocate the stack */
  1051.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  1052.       YYSTYPE *yyvs1 = yyvs;
  1053.       short *yyss1 = yyss;
  1054. #ifdef YYLSP_NEEDED
  1055.       YYLTYPE *yyls1 = yyls;
  1056. #endif
  1057.  
  1058.       /* Get the current used size of the three stacks, in elements.  */
  1059.       int size = yyssp - yyss + 1;
  1060.  
  1061. #ifdef yyoverflow
  1062.       /* Each stack pointer address is followed by the size of
  1063.      the data in use in that stack, in bytes.  */
  1064. #ifdef YYLSP_NEEDED
  1065.       /* This used to be a conditional around just the two extra args,
  1066.      but that might be undefined if yyoverflow is a macro.  */
  1067.       yyoverflow("parser stack overflow",
  1068.          &yyss1, size * sizeof (*yyssp),
  1069.          &yyvs1, size * sizeof (*yyvsp),
  1070.          &yyls1, size * sizeof (*yylsp),
  1071.          &yystacksize);
  1072. #else
  1073.       yyoverflow("parser stack overflow",
  1074.          &yyss1, size * sizeof (*yyssp),
  1075.          &yyvs1, size * sizeof (*yyvsp),
  1076.          &yystacksize);
  1077. #endif
  1078.  
  1079.       yyss = yyss1; yyvs = yyvs1;
  1080. #ifdef YYLSP_NEEDED
  1081.       yyls = yyls1;
  1082. #endif
  1083. #else /* no yyoverflow */
  1084.       /* Extend the stack our own way.  */
  1085.       if (yystacksize >= YYMAXDEPTH)
  1086.     {
  1087.       yyerror("parser stack overflow");
  1088.       return 2;
  1089.     }
  1090.       yystacksize *= 2;
  1091.       if (yystacksize > YYMAXDEPTH)
  1092.     yystacksize = YYMAXDEPTH;
  1093.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  1094.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  1095.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  1096.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  1097. #ifdef YYLSP_NEEDED
  1098.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  1099.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  1100. #endif
  1101. #endif /* no yyoverflow */
  1102.  
  1103.       yyssp = yyss + size - 1;
  1104.       yyvsp = yyvs + size - 1;
  1105. #ifdef YYLSP_NEEDED
  1106.       yylsp = yyls + size - 1;
  1107. #endif
  1108.  
  1109. #if YYDEBUG != 0
  1110.       if (yydebug)
  1111.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  1112. #endif
  1113.  
  1114.       if (yyssp >= yyss + yystacksize - 1)
  1115.     YYABORT;
  1116.     }
  1117.  
  1118. #if YYDEBUG != 0
  1119.   if (yydebug)
  1120.     fprintf(stderr, "Entering state %d\n", yystate);
  1121. #endif
  1122.  
  1123.   goto yybackup;
  1124.  yybackup:
  1125.  
  1126. /* Do appropriate processing given the current state.  */
  1127. /* Read a lookahead token if we need one and don't already have one.  */
  1128. /* yyresume: */
  1129.  
  1130.   /* First try to decide what to do without reference to lookahead token.  */
  1131.  
  1132.   yyn = yypact[yystate];
  1133.   if (yyn == YYFLAG)
  1134.     goto yydefault;
  1135.  
  1136.   /* Not known => get a lookahead token if don't already have one.  */
  1137.  
  1138.   /* yychar is either YYEMPTY or YYEOF
  1139.      or a valid token in external form.  */
  1140.  
  1141.   if (yychar == YYEMPTY)
  1142.     {
  1143. #if YYDEBUG != 0
  1144.       if (yydebug)
  1145.     fprintf(stderr, "Reading a token: ");
  1146. #endif
  1147.       yychar = YYLEX;
  1148.     }
  1149.  
  1150.   /* Convert token to internal form (in yychar1) for indexing tables with */
  1151.  
  1152.   if (yychar <= 0)        /* This means end of input. */
  1153.     {
  1154.       yychar1 = 0;
  1155.       yychar = YYEOF;        /* Don't call YYLEX any more */
  1156.  
  1157. #if YYDEBUG != 0
  1158.       if (yydebug)
  1159.     fprintf(stderr, "Now at end of input.\n");
  1160. #endif
  1161.     }
  1162.   else
  1163.     {
  1164.       yychar1 = YYTRANSLATE(yychar);
  1165.  
  1166. #if YYDEBUG != 0
  1167.       if (yydebug)
  1168.     {
  1169.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  1170.       /* Give the individual parser a way to print the precise meaning
  1171.          of a token, for further debugging info.  */
  1172. #ifdef YYPRINT
  1173.       YYPRINT (stderr, yychar, yylval);
  1174. #endif
  1175.       fprintf (stderr, ")\n");
  1176.     }
  1177. #endif
  1178.     }
  1179.  
  1180.   yyn += yychar1;
  1181.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  1182.     goto yydefault;
  1183.  
  1184.   yyn = yytable[yyn];
  1185.  
  1186.   /* yyn is what to do for this token type in this state.
  1187.      Negative => reduce, -yyn is rule number.
  1188.      Positive => shift, yyn is new state.
  1189.        New state is final state => don't bother to shift,
  1190.        just return success.
  1191.      0, or most negative number => error.  */
  1192.  
  1193.   if (yyn < 0)
  1194.     {
  1195.       if (yyn == YYFLAG)
  1196.     goto yyerrlab;
  1197.       yyn = -yyn;
  1198.       goto yyreduce;
  1199.     }
  1200.   else if (yyn == 0)
  1201.     goto yyerrlab;
  1202.  
  1203.   if (yyn == YYFINAL)
  1204.     YYACCEPT;
  1205.  
  1206.   /* Shift the lookahead token.  */
  1207.  
  1208. #if YYDEBUG != 0
  1209.   if (yydebug)
  1210.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  1211. #endif
  1212.  
  1213.   /* Discard the token being shifted unless it is eof.  */
  1214.   if (yychar != YYEOF)
  1215.     yychar = YYEMPTY;
  1216.  
  1217.   *++yyvsp = yylval;
  1218. #ifdef YYLSP_NEEDED
  1219.   *++yylsp = yylloc;
  1220. #endif
  1221.  
  1222.   /* count tokens shifted since error; after three, turn off error status.  */
  1223.   if (yyerrstatus) yyerrstatus--;
  1224.  
  1225.   yystate = yyn;
  1226.   goto yynewstate;
  1227.  
  1228. /* Do the default action for the current state.  */
  1229. yydefault:
  1230.  
  1231.   yyn = yydefact[yystate];
  1232.   if (yyn == 0)
  1233.     goto yyerrlab;
  1234.  
  1235. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  1236. yyreduce:
  1237.   yylen = yyr2[yyn];
  1238.   if (yylen > 0)
  1239.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  1240.  
  1241. #if YYDEBUG != 0
  1242.   if (yydebug)
  1243.     {
  1244.       int i;
  1245.  
  1246.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  1247.            yyn, yyrline[yyn]);
  1248.  
  1249.       /* Print the symbols being reduced, and their result.  */
  1250.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  1251.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  1252.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  1253.     }
  1254. #endif
  1255.  
  1256.  
  1257.   switch (yyn) {
  1258.  
  1259. case 1:
  1260. #line 150 "./awk.y"
  1261. {
  1262.             expression_value = yyvsp[-1].nodeval;
  1263.             check_funcs();
  1264.         ;
  1265.     break;}
  1266. case 2:
  1267. #line 158 "./awk.y"
  1268.             if (yyvsp[0].nodeval != NULL)
  1269.                 yyval.nodeval = yyvsp[0].nodeval;
  1270.             else
  1271.                 yyval.nodeval = NULL;
  1272.             yyerrok;
  1273.         ;
  1274.     break;}
  1275. case 3:
  1276. #line 167 "./awk.y"
  1277. {
  1278.             if (yyvsp[0].nodeval == NULL)
  1279.                 yyval.nodeval = yyvsp[-1].nodeval;
  1280.             else if (yyvsp[-1].nodeval == NULL)
  1281.                 yyval.nodeval = yyvsp[0].nodeval;
  1282.             else {
  1283.                 if (yyvsp[-1].nodeval->type != Node_rule_list)
  1284.                     yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_rule_list,
  1285.                         (NODE*) NULL);
  1286.                 yyval.nodeval = append_right(yyvsp[-1].nodeval,
  1287.                    node(yyvsp[0].nodeval, Node_rule_list, (NODE *) NULL));
  1288.             }
  1289.             yyerrok;
  1290.         ;
  1291.     break;}
  1292. case 4:
  1293. #line 181 "./awk.y"
  1294. { yyval.nodeval = NULL; ;
  1295.     break;}
  1296. case 5:
  1297. #line 182 "./awk.y"
  1298. { yyval.nodeval = NULL; ;
  1299.     break;}
  1300. case 6:
  1301. #line 183 "./awk.y"
  1302. { yyval.nodeval = NULL; ;
  1303.     break;}
  1304. case 7:
  1305. #line 187 "./awk.y"
  1306. { io_allowed = FALSE; ;
  1307.     break;}
  1308. case 8:
  1309. #line 189 "./awk.y"
  1310. {
  1311.         if (begin_block != NULL) {
  1312.             if (begin_block->type != Node_rule_list)
  1313.                 begin_block = node(begin_block, Node_rule_list,
  1314.                     (NODE *) NULL);
  1315.             (void) append_right(begin_block, node(
  1316.                 node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval),
  1317.                 Node_rule_list, (NODE *) NULL) );
  1318.         } else
  1319.             begin_block = node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval);
  1320.         yyval.nodeval = NULL;
  1321.         io_allowed = TRUE;
  1322.         yyerrok;
  1323.       ;
  1324.     break;}
  1325. case 9:
  1326. #line 203 "./awk.y"
  1327. { io_allowed = FALSE; ;
  1328.     break;}
  1329. case 10:
  1330. #line 205 "./awk.y"
  1331. {
  1332.         if (end_block != NULL) {
  1333.             if (end_block->type != Node_rule_list)
  1334.                 end_block = node(end_block, Node_rule_list,
  1335.                     (NODE *) NULL);
  1336.             (void) append_right (end_block, node(
  1337.                 node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval),
  1338.                 Node_rule_list, (NODE *) NULL));
  1339.         } else
  1340.             end_block = node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval);
  1341.         yyval.nodeval = NULL;
  1342.         io_allowed = TRUE;
  1343.         yyerrok;
  1344.       ;
  1345.     break;}
  1346. case 11:
  1347. #line 220 "./awk.y"
  1348. {
  1349.         warning("BEGIN blocks must have an action part");
  1350.         errcount++;
  1351.         yyerrok;
  1352.       ;
  1353.     break;}
  1354. case 12:
  1355. #line 226 "./awk.y"
  1356. {
  1357.         warning("END blocks must have an action part");
  1358.         errcount++;
  1359.         yyerrok;
  1360.       ;
  1361.     break;}
  1362. case 13:
  1363. #line 232 "./awk.y"
  1364. { yyval.nodeval = node(yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  1365.     break;}
  1366. case 14:
  1367. #line 234 "./awk.y"
  1368. { yyval.nodeval = node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  1369.     break;}
  1370. case 15:
  1371. #line 236 "./awk.y"
  1372. {
  1373.           yyval.nodeval = node(yyvsp[-1].nodeval,
  1374.                  Node_rule_node,
  1375.                  node(node(node(make_number(0.0),
  1376.                         Node_field_spec,
  1377.                         (NODE *) NULL),
  1378.                     Node_expression_list,
  1379.                     (NODE *) NULL),
  1380.                   Node_K_print,
  1381.                   (NODE *) NULL));
  1382.           yyerrok;
  1383.         ;
  1384.     break;}
  1385. case 16:
  1386. #line 249 "./awk.y"
  1387. {
  1388.             func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
  1389.             yyval.nodeval = NULL;
  1390.             yyerrok;
  1391.         ;
  1392.     break;}
  1393. case 17:
  1394. #line 258 "./awk.y"
  1395. { yyval.sval = yyvsp[0].sval; ;
  1396.     break;}
  1397. case 18:
  1398. #line 260 "./awk.y"
  1399. { yyval.sval = yyvsp[0].sval; ;
  1400.     break;}
  1401. case 19:
  1402. #line 262 "./awk.y"
  1403. {
  1404.         yyerror("%s() is a built-in function, it cannot be redefined",
  1405.             tokstart);
  1406.         errcount++;
  1407.         /* yyerrok; */
  1408.       ;
  1409.     break;}
  1410. case 22:
  1411. #line 277 "./awk.y"
  1412. {
  1413.             param_counter = 0;
  1414.         ;
  1415.     break;}
  1416. case 23:
  1417. #line 281 "./awk.y"
  1418. {
  1419.             yyval.nodeval = append_right(make_param(yyvsp[-4].sval), yyvsp[-2].nodeval);
  1420.             can_return = TRUE;
  1421.             /* check for duplicate parameter names */
  1422.             if (dup_parms(yyval.nodeval))
  1423.                 errcount++;
  1424.         ;
  1425.     break;}
  1426. case 24:
  1427. #line 292 "./awk.y"
  1428. {
  1429.         yyval.nodeval = yyvsp[-2].nodeval;
  1430.         can_return = FALSE;
  1431.       ;
  1432.     break;}
  1433. case 25:
  1434. #line 297 "./awk.y"
  1435. {
  1436.         yyval.nodeval = node((NODE *) NULL, Node_K_return, (NODE *) NULL);
  1437.         can_return = FALSE;
  1438.       ;
  1439.     break;}
  1440. case 26:
  1441. #line 306 "./awk.y"
  1442. { yyval.nodeval = yyvsp[0].nodeval; ;
  1443.     break;}
  1444. case 27:
  1445. #line 308 "./awk.y"
  1446. { yyval.nodeval = mkrangenode(node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval)); ;
  1447.     break;}
  1448. case 28:
  1449. #line 317 "./awk.y"
  1450. { ++want_regexp; ;
  1451.     break;}
  1452. case 29:
  1453. #line 319 "./awk.y"
  1454. {
  1455.           NODE *n;
  1456.           size_t len;
  1457.  
  1458.           getnode(n);
  1459.           n->type = Node_regex;
  1460.           len = strlen(yyvsp[-1].sval);
  1461.           n->re_exp = make_string(yyvsp[-1].sval, len);
  1462.           n->re_reg = make_regexp(yyvsp[-1].sval, len, FALSE, TRUE);
  1463.           n->re_text = NULL;
  1464.           n->re_flags = CONST;
  1465.           n->re_cnt = 1;
  1466.           yyval.nodeval = n;
  1467.         ;
  1468.     break;}
  1469. case 30:
  1470. #line 337 "./awk.y"
  1471. { yyval.nodeval = yyvsp[-3].nodeval; ;
  1472.     break;}
  1473. case 31:
  1474. #line 339 "./awk.y"
  1475. { yyval.nodeval = NULL; ;
  1476.     break;}
  1477. case 32:
  1478. #line 344 "./awk.y"
  1479. {
  1480.             yyval.nodeval = yyvsp[0].nodeval;
  1481.             if (do_lint && isnoeffect(yyval.nodeval->type))
  1482.                 warning("statement may have no effect");
  1483.         ;
  1484.     break;}
  1485. case 33:
  1486. #line 350 "./awk.y"
  1487. {
  1488.             if (yyvsp[-1].nodeval == NULL || yyvsp[-1].nodeval->type != Node_statement_list)
  1489.                 yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_statement_list, (NODE *) NULL);
  1490.                 yyval.nodeval = append_right(yyvsp[-1].nodeval,
  1491.                 node(yyvsp[0].nodeval, Node_statement_list, (NODE *)   NULL));
  1492.                 yyerrok;
  1493.         ;
  1494.     break;}
  1495. case 34:
  1496. #line 358 "./awk.y"
  1497. { yyval.nodeval = NULL; ;
  1498.     break;}
  1499. case 35:
  1500. #line 360 "./awk.y"
  1501. { yyval.nodeval = NULL; ;
  1502.     break;}
  1503. case 38:
  1504. #line 370 "./awk.y"
  1505. { yyval.nodeval = NULL; ;
  1506.     break;}
  1507. case 39:
  1508. #line 372 "./awk.y"
  1509. { yyval.nodeval = NULL; ;
  1510.     break;}
  1511. case 40:
  1512. #line 374 "./awk.y"
  1513. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1514.     break;}
  1515. case 41:
  1516. #line 376 "./awk.y"
  1517. { yyval.nodeval = yyvsp[0].nodeval; ;
  1518.     break;}
  1519. case 42:
  1520. #line 378 "./awk.y"
  1521. { yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
  1522.     break;}
  1523. case 43:
  1524. #line 380 "./awk.y"
  1525. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
  1526.     break;}
  1527. case 44:
  1528. #line 382 "./awk.y"
  1529. {
  1530.         yyval.nodeval = node(yyvsp[0].nodeval, Node_K_arrayfor,
  1531.             make_for_loop(variable(yyvsp[-5].sval, CAN_FREE, Node_var),
  1532.             (NODE *) NULL, variable(yyvsp[-3].sval, CAN_FREE, Node_var_array)));
  1533.       ;
  1534.     break;}
  1535. case 45:
  1536. #line 388 "./awk.y"
  1537. {
  1538.         yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *) make_for_loop(yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval));
  1539.       ;
  1540.     break;}
  1541. case 46:
  1542. #line 392 "./awk.y"
  1543. {
  1544.         yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for,
  1545.             (NODE *) make_for_loop(yyvsp[-6].nodeval, (NODE *) NULL, yyvsp[-3].nodeval));
  1546.       ;
  1547.     break;}
  1548. case 47:
  1549. #line 398 "./awk.y"
  1550. { yyval.nodeval = node((NODE *) NULL, Node_K_break, (NODE *) NULL); ;
  1551.     break;}
  1552. case 48:
  1553. #line 401 "./awk.y"
  1554. { yyval.nodeval = node((NODE *) NULL, Node_K_continue, (NODE *) NULL); ;
  1555.     break;}
  1556. case 49:
  1557. #line 403 "./awk.y"
  1558. { yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
  1559.     break;}
  1560. case 50:
  1561. #line 405 "./awk.y"
  1562. {
  1563.             if (yyvsp[-3].nodetypeval == Node_K_print && yyvsp[-2].nodeval == NULL) {
  1564.                 static int warned = FALSE;
  1565.  
  1566.                 yyvsp[-2].nodeval = node(node(make_number(0.0),
  1567.                            Node_field_spec,
  1568.                            (NODE *) NULL),
  1569.                       Node_expression_list,
  1570.                       (NODE *) NULL);
  1571.  
  1572.                 if (do_lint && ! io_allowed && ! warned) {
  1573.                     warned = TRUE;
  1574.                     warning(
  1575.     "plain `print' in BEGIN or END rule should probably be `print \"\"'");
  1576.                 }
  1577.             }
  1578.  
  1579.             yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval);
  1580.         ;
  1581.     break;}
  1582. case 51:
  1583. #line 425 "./awk.y"
  1584. { NODETYPE type;
  1585.  
  1586.           if (yyvsp[-1].nodeval) {
  1587.             if (yyvsp[-1].nodeval == lookup("file")) {
  1588.                 static int warned = FALSE;
  1589.  
  1590.                 if (! warned) {
  1591.                     warned = TRUE;
  1592.                     warning("`next file' is obsolete; use `nextfile'");
  1593.                 }
  1594.                 if (do_lint)
  1595.                     warning("`next file' is a gawk extension");
  1596.                 if (do_traditional) {
  1597.                     /*
  1598.                      * can't use yyerror, since may have overshot
  1599.                      * the source line
  1600.                      */
  1601.                     errcount++;
  1602.                     error("`next file' is a gawk extension");
  1603.                 }
  1604.                 if (! io_allowed) {
  1605.                     /* same thing */
  1606.                     errcount++;
  1607.                     error("`next file' used in BEGIN or END action");
  1608.                 }
  1609.                 type = Node_K_nextfile;
  1610.             } else {
  1611.                 errcount++;
  1612.                 error("illegal expression after `next'");
  1613.                 type = Node_K_next;    /* sanity */
  1614.             }
  1615.           } else {
  1616.             if (! io_allowed)
  1617.                 yyerror("`next' used in BEGIN or END action");
  1618.             type = Node_K_next;
  1619.           }
  1620.           yyval.nodeval = node((NODE *) NULL, type, (NODE *) NULL);
  1621.         ;
  1622.     break;}
  1623. case 52:
  1624. #line 464 "./awk.y"
  1625. {
  1626.           if (do_lint)
  1627.             warning("`nextfile' is a gawk extension");
  1628.           if (do_traditional) {
  1629.             /*
  1630.              * can't use yyerror, since may have overshot
  1631.              * the source line
  1632.              */
  1633.             errcount++;
  1634.             error("`nextfile' is a gawk extension");
  1635.           }
  1636.           if (! io_allowed) {
  1637.             /* same thing */
  1638.             errcount++;
  1639.             error("`nextfile' used in BEGIN or END action");
  1640.           }
  1641.           yyval.nodeval = node((NODE *) NULL, Node_K_nextfile, (NODE *) NULL);
  1642.         ;
  1643.     break;}
  1644. case 53:
  1645. #line 483 "./awk.y"
  1646. { yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_exit, (NODE *) NULL); ;
  1647.     break;}
  1648. case 54:
  1649. #line 485 "./awk.y"
  1650. {
  1651.           if (! can_return)
  1652.             yyerror("`return' used outside function context");
  1653.         ;
  1654.     break;}
  1655. case 55:
  1656. #line 490 "./awk.y"
  1657. { yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_return, (NODE *) NULL); ;
  1658.     break;}
  1659. case 56:
  1660. #line 492 "./awk.y"
  1661. { yyval.nodeval = node(variable(yyvsp[-4].sval, CAN_FREE, Node_var_array), Node_K_delete, yyvsp[-2].nodeval); ;
  1662.     break;}
  1663. case 57:
  1664. #line 494 "./awk.y"
  1665. {
  1666.           if (do_lint)
  1667.             warning("`delete array' is a gawk extension");
  1668.           if (do_traditional) {
  1669.             /*
  1670.              * can't use yyerror, since may have overshot
  1671.              * the source line
  1672.              */
  1673.             errcount++;
  1674.             error("`delete array' is a gawk extension");
  1675.           }
  1676.           yyval.nodeval = node(variable(yyvsp[-1].sval, CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL);
  1677.         ;
  1678.     break;}
  1679. case 58:
  1680. #line 508 "./awk.y"
  1681. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1682.     break;}
  1683. case 59:
  1684. #line 513 "./awk.y"
  1685. { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
  1686.     break;}
  1687. case 60:
  1688. #line 515 "./awk.y"
  1689. { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
  1690.     break;}
  1691. case 61:
  1692. #line 520 "./awk.y"
  1693. {
  1694.         yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if, 
  1695.             node(yyvsp[0].nodeval, Node_if_branches, (NODE *) NULL));
  1696.       ;
  1697.     break;}
  1698. case 62:
  1699. #line 526 "./awk.y"
  1700. { yyval.nodeval = node(yyvsp[-6].nodeval, Node_K_if,
  1701.                 node(yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
  1702.     break;}
  1703. case 63:
  1704. #line 532 "./awk.y"
  1705. { want_assign = FALSE; ;
  1706.     break;}
  1707. case 67:
  1708. #line 543 "./awk.y"
  1709. { yyval.nodeval = NULL; ;
  1710.     break;}
  1711. case 68:
  1712. #line 545 "./awk.y"
  1713. { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_input, (NODE *) NULL); ;
  1714.     break;}
  1715. case 69:
  1716. #line 550 "./awk.y"
  1717. { yyval.nodeval = NULL; ;
  1718.     break;}
  1719. case 70:
  1720. #line 552 "./awk.y"
  1721. { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_output, (NODE *) NULL); ;
  1722.     break;}
  1723. case 71:
  1724. #line 554 "./awk.y"
  1725. { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_append, (NODE *) NULL); ;
  1726.     break;}
  1727. case 72:
  1728. #line 556 "./awk.y"
  1729. { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_pipe, (NODE *) NULL); ;
  1730.     break;}
  1731. case 73:
  1732. #line 561 "./awk.y"
  1733. { yyval.nodeval = NULL; ;
  1734.     break;}
  1735. case 74:
  1736. #line 563 "./awk.y"
  1737. { yyval.nodeval = yyvsp[0].nodeval; ;
  1738.     break;}
  1739. case 75:
  1740. #line 568 "./awk.y"
  1741. { yyval.nodeval = make_param(yyvsp[0].sval); ;
  1742.     break;}
  1743. case 76:
  1744. #line 570 "./awk.y"
  1745. { yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ;
  1746.     break;}
  1747. case 77:
  1748. #line 572 "./awk.y"
  1749. { yyval.nodeval = NULL; ;
  1750.     break;}
  1751. case 78:
  1752. #line 574 "./awk.y"
  1753. { yyval.nodeval = NULL; ;
  1754.     break;}
  1755. case 79:
  1756. #line 576 "./awk.y"
  1757. { yyval.nodeval = NULL; ;
  1758.     break;}
  1759. case 80:
  1760. #line 582 "./awk.y"
  1761. { yyval.nodeval = NULL; ;
  1762.     break;}
  1763. case 81:
  1764. #line 584 "./awk.y"
  1765. { yyval.nodeval = yyvsp[0].nodeval; ;
  1766.     break;}
  1767. case 82:
  1768. #line 589 "./awk.y"
  1769. { yyval.nodeval = NULL; ;
  1770.     break;}
  1771. case 83:
  1772. #line 591 "./awk.y"
  1773. { yyval.nodeval = yyvsp[0].nodeval; ;
  1774.     break;}
  1775. case 84:
  1776. #line 596 "./awk.y"
  1777. { yyval.nodeval = node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL); ;
  1778.     break;}
  1779. case 85:
  1780. #line 598 "./awk.y"
  1781. {
  1782.         yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1783.             node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL));
  1784.         yyerrok;
  1785.       ;
  1786.     break;}
  1787. case 86:
  1788. #line 604 "./awk.y"
  1789. { yyval.nodeval = NULL; ;
  1790.     break;}
  1791. case 87:
  1792. #line 606 "./awk.y"
  1793. { yyval.nodeval = NULL; ;
  1794.     break;}
  1795. case 88:
  1796. #line 608 "./awk.y"
  1797. { yyval.nodeval = NULL; ;
  1798.     break;}
  1799. case 89:
  1800. #line 610 "./awk.y"
  1801. { yyval.nodeval = NULL; ;
  1802.     break;}
  1803. case 90:
  1804. #line 615 "./awk.y"
  1805. { yyval.nodeval = NULL; ;
  1806.     break;}
  1807. case 91:
  1808. #line 617 "./awk.y"
  1809. { yyval.nodeval = yyvsp[0].nodeval; ;
  1810.     break;}
  1811. case 92:
  1812. #line 622 "./awk.y"
  1813. { yyval.nodeval = node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL); ;
  1814.     break;}
  1815. case 93:
  1816. #line 624 "./awk.y"
  1817. {
  1818.             yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1819.                 node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL));
  1820.             yyerrok;
  1821.         ;
  1822.     break;}
  1823. case 94:
  1824. #line 630 "./awk.y"
  1825. { yyval.nodeval = NULL; ;
  1826.     break;}
  1827. case 95:
  1828. #line 632 "./awk.y"
  1829. { yyval.nodeval = NULL; ;
  1830.     break;}
  1831. case 96:
  1832. #line 634 "./awk.y"
  1833. { yyval.nodeval = NULL; ;
  1834.     break;}
  1835. case 97:
  1836. #line 636 "./awk.y"
  1837. { yyval.nodeval = NULL; ;
  1838.     break;}
  1839. case 98:
  1840. #line 641 "./awk.y"
  1841. { want_assign = FALSE; ;
  1842.     break;}
  1843. case 99:
  1844. #line 643 "./awk.y"
  1845. {
  1846.           if (do_lint && yyvsp[0].nodeval->type == Node_regex)
  1847.             warning("Regular expression on left of assignment.");
  1848.           yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval);
  1849.         ;
  1850.     break;}
  1851. case 100:
  1852. #line 649 "./awk.y"
  1853. { yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_in_array, yyvsp[-3].nodeval); ;
  1854.     break;}
  1855. case 101:
  1856. #line 651 "./awk.y"
  1857. {
  1858.           yyval.nodeval = node(yyvsp[0].nodeval, Node_K_getline,
  1859.              node(yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *) NULL));
  1860.         ;
  1861.     break;}
  1862. case 102:
  1863. #line 656 "./awk.y"
  1864. {
  1865.           if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
  1866.             warning("non-redirected getline undefined inside BEGIN or END action");
  1867.           yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1868.         ;
  1869.     break;}
  1870. case 103:
  1871. #line 662 "./awk.y"
  1872. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  1873.     break;}
  1874. case 104:
  1875. #line 664 "./awk.y"
  1876. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  1877.     break;}
  1878. case 105:
  1879. #line 666 "./awk.y"
  1880. {
  1881.           if (yyvsp[-2].nodeval->type == Node_regex)
  1882.             warning("Regular expression on left of MATCH operator.");
  1883.           yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval));
  1884.         ;
  1885.     break;}
  1886. case 106:
  1887. #line 672 "./awk.y"
  1888. {
  1889.           yyval.nodeval = yyvsp[0].nodeval;
  1890.           if (do_lint && tokstart[0] == '*') {
  1891.             /* possible C comment */
  1892.             int n = strlen(tokstart) - 1;
  1893.             if (tokstart[n] == '*')
  1894.                 warning("regexp looks like a C comment, but is not");
  1895.           }
  1896.         ;
  1897.     break;}
  1898. case 107:
  1899. #line 682 "./awk.y"
  1900. {
  1901.           yyval.nodeval = node(node(make_number(0.0),
  1902.                  Node_field_spec,
  1903.                  (NODE *) NULL),
  1904.                     Node_nomatch,
  1905.                 yyvsp[0].nodeval);
  1906.         ;
  1907.     break;}
  1908. case 108:
  1909. #line 690 "./awk.y"
  1910. { yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_in_array, yyvsp[-2].nodeval); ;
  1911.     break;}
  1912. case 109:
  1913. #line 692 "./awk.y"
  1914. {
  1915.           if (do_lint && yyvsp[0].nodeval->type == Node_regex)
  1916.             warning("Regular expression on left of comparison.");
  1917.           yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
  1918.         ;
  1919.     break;}
  1920. case 110:
  1921. #line 698 "./awk.y"
  1922. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ;
  1923.     break;}
  1924. case 111:
  1925. #line 700 "./awk.y"
  1926. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ;
  1927.     break;}
  1928. case 112:
  1929. #line 702 "./awk.y"
  1930. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
  1931.     break;}
  1932. case 113:
  1933. #line 704 "./awk.y"
  1934. { yyval.nodeval = yyvsp[0].nodeval; ;
  1935.     break;}
  1936. case 114:
  1937. #line 706 "./awk.y"
  1938. { yyval.nodeval = node(yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1939.     break;}
  1940. case 115:
  1941. #line 711 "./awk.y"
  1942. { want_assign = FALSE; ;
  1943.     break;}
  1944. case 116:
  1945. #line 713 "./awk.y"
  1946. { yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
  1947.     break;}
  1948. case 117:
  1949. #line 715 "./awk.y"
  1950. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  1951.     break;}
  1952. case 118:
  1953. #line 717 "./awk.y"
  1954. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  1955.     break;}
  1956. case 119:
  1957. #line 719 "./awk.y"
  1958. {
  1959.           if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
  1960.             warning("non-redirected getline undefined inside BEGIN or END action");
  1961.           yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1962.         ;
  1963.     break;}
  1964. case 120:
  1965. #line 725 "./awk.y"
  1966. { yyval.nodeval = yyvsp[0].nodeval; ;
  1967.     break;}
  1968. case 121:
  1969. #line 727 "./awk.y"
  1970. { yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
  1971.     break;}
  1972. case 122:
  1973. #line 729 "./awk.y"
  1974. { yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval)); ;
  1975.     break;}
  1976. case 123:
  1977. #line 731 "./awk.y"
  1978. { yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_in_array, yyvsp[-2].nodeval); ;
  1979.     break;}
  1980. case 124:
  1981. #line 733 "./awk.y"
  1982. { yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1983.     break;}
  1984. case 125:
  1985. #line 735 "./awk.y"
  1986. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
  1987.     break;}
  1988. case 126:
  1989. #line 737 "./awk.y"
  1990. { yyval.nodeval = yyvsp[0].nodeval; ;
  1991.     break;}
  1992. case 127:
  1993. #line 739 "./awk.y"
  1994. { yyval.nodeval = node(yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1995.     break;}
  1996. case 129:
  1997. #line 746 "./awk.y"
  1998. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
  1999.     break;}
  2000. case 130:
  2001. #line 748 "./awk.y"
  2002. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
  2003.     break;}
  2004. case 131:
  2005. #line 750 "./awk.y"
  2006. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
  2007.     break;}
  2008. case 132:
  2009. #line 752 "./awk.y"
  2010. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
  2011.     break;}
  2012. case 133:
  2013. #line 754 "./awk.y"
  2014. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
  2015.     break;}
  2016. case 134:
  2017. #line 756 "./awk.y"
  2018. { yyval.nodeval = node(yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
  2019.     break;}
  2020. case 135:
  2021. #line 758 "./awk.y"
  2022. { yyval.nodeval = node(yyvsp[-1].nodeval, Node_postincrement, (NODE *) NULL); ;
  2023.     break;}
  2024. case 136:
  2025. #line 760 "./awk.y"
  2026. { yyval.nodeval = node(yyvsp[-1].nodeval, Node_postdecrement, (NODE *) NULL); ;
  2027.     break;}
  2028. case 137:
  2029. #line 765 "./awk.y"
  2030. { yyval.nodeval = node(yyvsp[0].nodeval, Node_not, (NODE *) NULL); ;
  2031.     break;}
  2032. case 138:
  2033. #line 767 "./awk.y"
  2034. { yyval.nodeval = yyvsp[-1].nodeval; ;
  2035.     break;}
  2036. case 139:
  2037. #line 770 "./awk.y"
  2038. { yyval.nodeval = snode(yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
  2039.     break;}
  2040. case 140:
  2041. #line 772 "./awk.y"
  2042. { yyval.nodeval = snode(yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
  2043.     break;}
  2044. case 141:
  2045. #line 774 "./awk.y"
  2046. {
  2047.         if (do_lint)
  2048.             warning("call of `length' without parentheses is not portable");
  2049.         yyval.nodeval = snode((NODE *) NULL, Node_builtin, (int) yyvsp[0].lval);
  2050.         if (do_posix)
  2051.             warning("call of `length' without parentheses is deprecated by POSIX");
  2052.       ;
  2053.     break;}
  2054. case 142:
  2055. #line 782 "./awk.y"
  2056. {
  2057.         yyval.nodeval = node(yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
  2058.         func_use(yyvsp[-3].sval, FUNC_USE);
  2059.         param_sanity(yyvsp[-1].nodeval);
  2060.         free(yyvsp[-3].sval);
  2061.       ;
  2062.     break;}
  2063. case 144:
  2064. #line 790 "./awk.y"
  2065. { yyval.nodeval = node(yyvsp[0].nodeval, Node_preincrement, (NODE *) NULL); ;
  2066.     break;}
  2067. case 145:
  2068. #line 792 "./awk.y"
  2069. { yyval.nodeval = node(yyvsp[0].nodeval, Node_predecrement, (NODE *) NULL); ;
  2070.     break;}
  2071. case 146:
  2072. #line 794 "./awk.y"
  2073. { yyval.nodeval = yyvsp[0].nodeval; ;
  2074.     break;}
  2075. case 147:
  2076. #line 796 "./awk.y"
  2077. { yyval.nodeval = yyvsp[0].nodeval; ;
  2078.     break;}
  2079. case 148:
  2080. #line 799 "./awk.y"
  2081. {
  2082.           if (yyvsp[0].nodeval->type == Node_val) {
  2083.             yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
  2084.             yyval.nodeval = yyvsp[0].nodeval;
  2085.           } else
  2086.             yyval.nodeval = node(yyvsp[0].nodeval, Node_unary_minus, (NODE *) NULL);
  2087.         ;
  2088.     break;}
  2089. case 149:
  2090. #line 807 "./awk.y"
  2091. {
  2092.           /*
  2093.            * was: $$ = $2
  2094.            * POSIX semantics: force a conversion to numeric type
  2095.            */
  2096.           yyval.nodeval = node (make_number(0.0), Node_plus, yyvsp[0].nodeval);
  2097.         ;
  2098.     break;}
  2099. case 150:
  2100. #line 818 "./awk.y"
  2101. { yyval.nodeval = NULL; ;
  2102.     break;}
  2103. case 151:
  2104. #line 820 "./awk.y"
  2105. { yyval.nodeval = yyvsp[0].nodeval; ;
  2106.     break;}
  2107. case 152:
  2108. #line 825 "./awk.y"
  2109. { yyval.nodeval = variable(yyvsp[0].sval, CAN_FREE, Node_var); ;
  2110.     break;}
  2111. case 153:
  2112. #line 827 "./awk.y"
  2113. {
  2114.         if (yyvsp[-1].nodeval->rnode == NULL) {
  2115.             yyval.nodeval = node(variable(yyvsp[-3].sval, CAN_FREE, Node_var_array), Node_subscript, yyvsp[-1].nodeval->lnode);
  2116.             freenode(yyvsp[-1].nodeval);
  2117.         } else
  2118.             yyval.nodeval = node(variable(yyvsp[-3].sval, CAN_FREE, Node_var_array), Node_subscript, yyvsp[-1].nodeval);
  2119.         ;
  2120.     break;}
  2121. case 154:
  2122. #line 835 "./awk.y"
  2123. { yyval.nodeval = node(yyvsp[0].nodeval, Node_field_spec, (NODE *) NULL); ;
  2124.     break;}
  2125. case 156:
  2126. #line 843 "./awk.y"
  2127. { yyerrok; ;
  2128.     break;}
  2129. case 157:
  2130. #line 847 "./awk.y"
  2131. { yyerrok; ;
  2132.     break;}
  2133. case 160:
  2134. #line 856 "./awk.y"
  2135. { yyerrok; want_assign = FALSE; ;
  2136.     break;}
  2137. case 161:
  2138. #line 859 "./awk.y"
  2139. { yyerrok; ;
  2140.     break;}
  2141. }
  2142.    /* the action file gets copied in in place of this dollarsign */
  2143. #line 465 "/usr/local/lib/bison.simple"
  2144.  
  2145.   yyvsp -= yylen;
  2146.   yyssp -= yylen;
  2147. #ifdef YYLSP_NEEDED
  2148.   yylsp -= yylen;
  2149. #endif
  2150.  
  2151. #if YYDEBUG != 0
  2152.   if (yydebug)
  2153.     {
  2154.       short *ssp1 = yyss - 1;
  2155.       fprintf (stderr, "state stack now");
  2156.       while (ssp1 != yyssp)
  2157.     fprintf (stderr, " %d", *++ssp1);
  2158.       fprintf (stderr, "\n");
  2159.     }
  2160. #endif
  2161.  
  2162.   *++yyvsp = yyval;
  2163.  
  2164. #ifdef YYLSP_NEEDED
  2165.   yylsp++;
  2166.   if (yylen == 0)
  2167.     {
  2168.       yylsp->first_line = yylloc.first_line;
  2169.       yylsp->first_column = yylloc.first_column;
  2170.       yylsp->last_line = (yylsp-1)->last_line;
  2171.       yylsp->last_column = (yylsp-1)->last_column;
  2172.       yylsp->text = 0;
  2173.     }
  2174.   else
  2175.     {
  2176.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  2177.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  2178.     }
  2179. #endif
  2180.  
  2181.   /* Now "shift" the result of the reduction.
  2182.      Determine what state that goes to,
  2183.      based on the state we popped back to
  2184.      and the rule number reduced by.  */
  2185.  
  2186.   yyn = yyr1[yyn];
  2187.  
  2188.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  2189.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  2190.     yystate = yytable[yystate];
  2191.   else
  2192.     yystate = yydefgoto[yyn - YYNTBASE];
  2193.  
  2194.   goto yynewstate;
  2195.  
  2196. yyerrlab:   /* here on detecting error */
  2197.  
  2198.   if (! yyerrstatus)
  2199.     /* If not already recovering from an error, report this error.  */
  2200.     {
  2201.       ++yynerrs;
  2202.  
  2203. #ifdef YYERROR_VERBOSE
  2204.       yyn = yypact[yystate];
  2205.  
  2206.       if (yyn > YYFLAG && yyn < YYLAST)
  2207.     {
  2208.       int size = 0;
  2209.       char *msg;
  2210.       int x, count;
  2211.  
  2212.       count = 0;
  2213.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  2214.       for (x = (yyn < 0 ? -yyn : 0);
  2215.            x < (sizeof(yytname) / sizeof(char *)); x++)
  2216.         if (yycheck[x + yyn] == x)
  2217.           size += strlen(yytname[x]) + 15, count++;
  2218.       msg = (char *) malloc(size + 15);
  2219.       if (msg != 0)
  2220.         {
  2221.           strcpy(msg, "parse error");
  2222.  
  2223.           if (count < 5)
  2224.         {
  2225.           count = 0;
  2226.           for (x = (yyn < 0 ? -yyn : 0);
  2227.                x < (sizeof(yytname) / sizeof(char *)); x++)
  2228.             if (yycheck[x + yyn] == x)
  2229.               {
  2230.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  2231.             strcat(msg, yytname[x]);
  2232.             strcat(msg, "'");
  2233.             count++;
  2234.               }
  2235.         }
  2236.           yyerror(msg);
  2237.           free(msg);
  2238.         }
  2239.       else
  2240.         yyerror ("parse error; also virtual memory exceeded");
  2241.     }
  2242.       else
  2243. #endif /* YYERROR_VERBOSE */
  2244.     yyerror("parse error");
  2245.     }
  2246.  
  2247.   goto yyerrlab1;
  2248. yyerrlab1:   /* here on error raised explicitly by an action */
  2249.  
  2250.   if (yyerrstatus == 3)
  2251.     {
  2252.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  2253.  
  2254.       /* return failure if at end of input */
  2255.       if (yychar == YYEOF)
  2256.     YYABORT;
  2257.  
  2258. #if YYDEBUG != 0
  2259.       if (yydebug)
  2260.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  2261. #endif
  2262.  
  2263.       yychar = YYEMPTY;
  2264.     }
  2265.  
  2266.   /* Else will try to reuse lookahead token
  2267.      after shifting the error token.  */
  2268.  
  2269.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  2270.  
  2271.   goto yyerrhandle;
  2272.  
  2273. yyerrdefault:  /* current state does not do anything special for the error token. */
  2274.  
  2275. #if 0
  2276.   /* This is wrong; only states that explicitly want error tokens
  2277.      should shift them.  */
  2278.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  2279.   if (yyn) goto yydefault;
  2280. #endif
  2281.  
  2282. yyerrpop:   /* pop the current state because it cannot handle the error token */
  2283.  
  2284.   if (yyssp == yyss) YYABORT;
  2285.   yyvsp--;
  2286.   yystate = *--yyssp;
  2287. #ifdef YYLSP_NEEDED
  2288.   yylsp--;
  2289. #endif
  2290.  
  2291. #if YYDEBUG != 0
  2292.   if (yydebug)
  2293.     {
  2294.       short *ssp1 = yyss - 1;
  2295.       fprintf (stderr, "Error: state stack now");
  2296.       while (ssp1 != yyssp)
  2297.     fprintf (stderr, " %d", *++ssp1);
  2298.       fprintf (stderr, "\n");
  2299.     }
  2300. #endif
  2301.  
  2302. yyerrhandle:
  2303.  
  2304.   yyn = yypact[yystate];
  2305.   if (yyn == YYFLAG)
  2306.     goto yyerrdefault;
  2307.  
  2308.   yyn += YYTERROR;
  2309.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  2310.     goto yyerrdefault;
  2311.  
  2312.   yyn = yytable[yyn];
  2313.   if (yyn < 0)
  2314.     {
  2315.       if (yyn == YYFLAG)
  2316.     goto yyerrpop;
  2317.       yyn = -yyn;
  2318.       goto yyreduce;
  2319.     }
  2320.   else if (yyn == 0)
  2321.     goto yyerrpop;
  2322.  
  2323.   if (yyn == YYFINAL)
  2324.     YYACCEPT;
  2325.  
  2326. #if YYDEBUG != 0
  2327.   if (yydebug)
  2328.     fprintf(stderr, "Shifting error token, ");
  2329. #endif
  2330.  
  2331.   *++yyvsp = yylval;
  2332. #ifdef YYLSP_NEEDED
  2333.   *++yylsp = yylloc;
  2334. #endif
  2335.  
  2336.   yystate = yyn;
  2337.   goto yynewstate;
  2338. }
  2339. #line 862 "./awk.y"
  2340.  
  2341.  
  2342. struct token {
  2343.     const char *operator;        /* text to match */
  2344.     NODETYPE value;        /* node type */
  2345.     int class;        /* lexical class */
  2346.     unsigned flags;        /* # of args. allowed and compatability */
  2347. #    define    ARGS    0xFF    /* 0, 1, 2, 3 args allowed (any combination */
  2348. #    define    A(n)    (1<<(n))
  2349. #    define    VERSION    0xFF00    /* old awk is zero */
  2350. #    define    NOT_OLD        0x0100    /* feature not in old awk */
  2351. #    define    NOT_POSIX    0x0200    /* feature not in POSIX */
  2352. #    define    GAWKX        0x0400    /* gawk extension */
  2353. #    define    RESX        0x0800    /* Bell Labs Research extension */
  2354.     NODE *(*ptr)();        /* function that implements this keyword */
  2355. };
  2356.  
  2357. extern NODE
  2358.     *do_exp(),    *do_getline(),    *do_index(),    *do_length(),
  2359.     *do_sqrt(),    *do_log(),    *do_sprintf(),    *do_substr(),
  2360.     *do_split(),    *do_system(),    *do_int(),    *do_close(),
  2361.     *do_atan2(),    *do_sin(),    *do_cos(),    *do_rand(),
  2362.     *do_srand(),    *do_match(),    *do_tolower(),    *do_toupper(),
  2363.     *do_sub(),    *do_gsub(),    *do_strftime(),    *do_systime(),
  2364.     *do_fflush();
  2365.  
  2366. /* Tokentab is sorted ascii ascending order, so it can be binary searched. */
  2367.  
  2368. static struct token tokentab[] = {
  2369. {"BEGIN",    Node_illegal,     LEX_BEGIN,    0,        0},
  2370. {"END",        Node_illegal,     LEX_END,    0,        0},
  2371. {"atan2",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2),    do_atan2},
  2372. {"break",    Node_K_break,     LEX_BREAK,    0,        0},
  2373. {"close",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_close},
  2374. {"continue",    Node_K_continue, LEX_CONTINUE,    0,        0},
  2375. {"cos",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_cos},
  2376. {"delete",    Node_K_delete,     LEX_DELETE,    NOT_OLD,    0},
  2377. {"do",        Node_K_do,     LEX_DO,    NOT_OLD,    0},
  2378. {"else",    Node_illegal,     LEX_ELSE,    0,        0},
  2379. {"exit",    Node_K_exit,     LEX_EXIT,    0,        0},
  2380. {"exp",        Node_builtin,     LEX_BUILTIN,    A(1),        do_exp},
  2381. {"fflush",    Node_builtin,     LEX_BUILTIN,    RESX|A(0)|A(1), do_fflush},
  2382. {"for",        Node_K_for,     LEX_FOR,    0,        0},
  2383. {"func",    Node_K_function, LEX_FUNCTION,    NOT_POSIX|NOT_OLD,    0},
  2384. {"function",    Node_K_function, LEX_FUNCTION,    NOT_OLD,    0},
  2385. {"gensub",    Node_builtin,     LEX_BUILTIN,    GAWKX|A(3)|A(4), do_gensub},
  2386. {"getline",    Node_K_getline,     LEX_GETLINE,    NOT_OLD,    0},
  2387. {"gsub",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2)|A(3), do_gsub},
  2388. {"if",        Node_K_if,     LEX_IF,    0,        0},
  2389. {"in",        Node_illegal,     LEX_IN,    0,        0},
  2390. {"index",    Node_builtin,     LEX_BUILTIN,    A(2),        do_index},
  2391. {"int",        Node_builtin,     LEX_BUILTIN,    A(1),        do_int},
  2392. {"length",    Node_builtin,     LEX_LENGTH,    A(0)|A(1),    do_length},
  2393. {"log",        Node_builtin,     LEX_BUILTIN,    A(1),        do_log},
  2394. {"match",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2),    do_match},
  2395. {"next",    Node_K_next,     LEX_NEXT,    0,        0},
  2396. {"nextfile",    Node_K_nextfile, LEX_NEXTFILE,    GAWKX,        0},
  2397. {"print",    Node_K_print,     LEX_PRINT,    0,        0},
  2398. {"printf",    Node_K_printf,     LEX_PRINTF,    0,        0},
  2399. {"rand",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(0),    do_rand},
  2400. {"return",    Node_K_return,     LEX_RETURN,    NOT_OLD,    0},
  2401. {"sin",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_sin},
  2402. {"split",    Node_builtin,     LEX_BUILTIN,    A(2)|A(3),    do_split},
  2403. {"sprintf",    Node_builtin,     LEX_BUILTIN,    0,        do_sprintf},
  2404. {"sqrt",    Node_builtin,     LEX_BUILTIN,    A(1),        do_sqrt},
  2405. {"srand",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(0)|A(1), do_srand},
  2406. {"strftime",    Node_builtin,     LEX_BUILTIN,    GAWKX|A(0)|A(1)|A(2), do_strftime},
  2407. {"sub",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2)|A(3), do_sub},
  2408. {"substr",    Node_builtin,     LEX_BUILTIN,    A(2)|A(3),    do_substr},
  2409. {"system",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_system},
  2410. {"systime",    Node_builtin,     LEX_BUILTIN,    GAWKX|A(0),    do_systime},
  2411. {"tolower",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_tolower},
  2412. {"toupper",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_toupper},
  2413. {"while",    Node_K_while,     LEX_WHILE,    0,        0},
  2414. };
  2415.  
  2416. /* yyerror --- print a syntax error message, show where */
  2417.  
  2418. #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
  2419. static void
  2420. yyerror(const char *m, ...)
  2421. #else
  2422. /* VARARGS0 */
  2423. static void
  2424. yyerror(va_alist)
  2425. va_dcl
  2426. #endif
  2427. {
  2428.     va_list args;
  2429.     const char *mesg = NULL;
  2430.     register char *bp, *cp;
  2431.     char *scan;
  2432.     char buf[120];
  2433.     static char end_of_file_line[] = "(END OF FILE)";
  2434.  
  2435.     errcount++;
  2436.     /* Find the current line in the input file */
  2437.     if (lexptr && lexeme) {
  2438.         if (thisline == NULL) {
  2439.             cp = lexeme;
  2440.             if (*cp == '\n') {
  2441.                 cp--;
  2442.                 mesg = "unexpected newline";
  2443.             }
  2444.             for (; cp != lexptr_begin && *cp != '\n'; --cp)
  2445.                 continue;
  2446.             if (*cp == '\n')
  2447.                 cp++;
  2448.             thisline = cp;
  2449.         }
  2450.         /* NL isn't guaranteed */
  2451.         bp = lexeme;
  2452.         while (bp < lexend && *bp && *bp != '\n')
  2453.             bp++;
  2454.     } else {
  2455.         thisline = end_of_file_line;
  2456.         bp = thisline + strlen(thisline);
  2457.     }
  2458.     msg("%.*s", (int) (bp - thisline), thisline);
  2459.     bp = buf;
  2460.     cp = buf + sizeof(buf) - 24;    /* 24 more than longest msg. input */
  2461.     if (lexptr != NULL) {
  2462.         scan = thisline;
  2463.         while (bp < cp && scan < lexeme)
  2464.             if (*scan++ == '\t')
  2465.                 *bp++ = '\t';
  2466.             else
  2467.                 *bp++ = ' ';
  2468.         *bp++ = '^';
  2469.         *bp++ = ' ';
  2470.     }
  2471. #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
  2472.     va_start(args, m);
  2473.     if (mesg == NULL)
  2474.         mesg = m;
  2475. #else
  2476.     va_start(args);
  2477.     if (mesg == NULL)
  2478.         mesg = va_arg(args, char *);
  2479. #endif
  2480.     strcpy(bp, mesg);
  2481.     err("", buf, args);
  2482.     va_end(args);
  2483.     exit(2);
  2484. }
  2485.  
  2486. /* get_src_buf --- read the next buffer of source program */
  2487.  
  2488. static char *
  2489. get_src_buf()
  2490. {
  2491.     static int samefile = FALSE;
  2492.     static int nextfile = 0;
  2493.     static char *buf = NULL;
  2494.     static int fd;
  2495.     int n;
  2496.     register char *scan;
  2497.     static int len = 0;
  2498.     static int did_newline = FALSE;
  2499.     struct stat sbuf;
  2500.  
  2501. #    define    SLOP    128    /* enough space to hold most source lines */
  2502.  
  2503. again:
  2504.     if (nextfile > numfiles)
  2505.         return NULL;
  2506.  
  2507.     if (srcfiles[nextfile].stype == CMDLINE) {
  2508.         if (len == 0) {
  2509.             len = strlen(srcfiles[nextfile].val);
  2510.             if (len == 0) {
  2511.                 /*
  2512.                  * Yet Another Special case:
  2513.                  *    gawk '' /path/name
  2514.                  * Sigh.
  2515.                  */
  2516.                 static int warned = FALSE;
  2517.  
  2518.                 if (do_lint && ! warned) {
  2519.                     warned = TRUE;
  2520.                     warning("empty program text on command line");
  2521.                 }
  2522.                 ++nextfile;
  2523.                 goto again;
  2524.             }
  2525.             sourceline = 1;
  2526.             lexptr = lexptr_begin = srcfiles[nextfile].val;
  2527.             lexend = lexptr + len;
  2528.         } else if (! did_newline && *(lexptr-1) != '\n') {
  2529.             /*
  2530.              * The following goop is to ensure that the source
  2531.              * ends with a newline and that the entire current
  2532.              * line is available for error messages.
  2533.              */
  2534.             int offset;
  2535.  
  2536.             did_newline = TRUE;
  2537.             offset = lexptr - lexeme;
  2538.             for (scan = lexeme; scan > lexptr_begin; scan--)
  2539.                 if (*scan == '\n') {
  2540.                     scan++;
  2541.                     break;
  2542.                 }
  2543.             len = lexptr - scan;
  2544.             emalloc(buf, char *, len+1, "get_src_buf");
  2545.             memcpy(buf, scan, len);
  2546.             thisline = buf;
  2547.             lexptr = buf + len;
  2548.             *lexptr = '\n';
  2549.             lexeme = lexptr - offset;
  2550.             lexptr_begin = buf;
  2551.             lexend = lexptr + 1;
  2552.         } else {
  2553.             len = 0;
  2554.             lexeme = lexptr = lexptr_begin = NULL;
  2555.         }
  2556.         if (lexptr == NULL && ++nextfile <= numfiles)
  2557.             goto again;
  2558.         return lexptr;
  2559.     }
  2560.     if (! samefile) {
  2561.         source = srcfiles[nextfile].val;
  2562.         if (source == NULL) {
  2563.             if (buf != NULL) {
  2564.                 free(buf);
  2565.                 buf = NULL;
  2566.             }
  2567.             len = 0;
  2568.             return lexeme = lexptr = lexptr_begin = NULL;
  2569.         }
  2570.         fd = pathopen(source);
  2571.         if (fd <= INVALID_HANDLE) {
  2572.             char *in;
  2573.  
  2574.             /* suppress file name and line no. in error mesg */
  2575.             in = source;
  2576.             source = NULL;
  2577.             fatal("can't open source file \"%s\" for reading (%s)",
  2578.                 in, strerror(errno));
  2579.         }
  2580.         len = optimal_bufsize(fd, & sbuf);
  2581.         if (sbuf.st_size == 0) {
  2582.             static int warned = FALSE;
  2583.  
  2584.             if (do_lint && ! warned) {
  2585.                 warned = TRUE;
  2586.                 warning("source file `%s' is empty", source);
  2587.             }
  2588.             close(fd);
  2589.             ++nextfile;
  2590.             goto again;
  2591.         }
  2592.         if (buf != NULL)
  2593.             free(buf);
  2594.         emalloc(buf, char *, len + SLOP, "get_src_buf");
  2595.         lexptr_begin = buf + SLOP;
  2596.         samefile = TRUE;
  2597.         sourceline = 1;
  2598.     } else {
  2599.         /*
  2600.          * Here, we retain the current source line (up to length SLOP)
  2601.          * in the beginning of the buffer that was overallocated above
  2602.          */
  2603.         int offset;
  2604.         int linelen;
  2605.  
  2606.         offset = lexptr - lexeme;
  2607.         for (scan = lexeme; scan > lexptr_begin; scan--)
  2608.             if (*scan == '\n') {
  2609.                 scan++;
  2610.                 break;
  2611.             }
  2612.         linelen = lexptr - scan;
  2613.         if (linelen > SLOP)
  2614.             linelen = SLOP;
  2615.         thisline = buf + SLOP - linelen;
  2616.         memcpy(thisline, scan, linelen);
  2617.         lexeme = buf + SLOP - offset;
  2618.         lexptr_begin = thisline;
  2619.     }
  2620.     n = read(fd, buf + SLOP, len);
  2621.     if (n == -1)
  2622.         fatal("can't read sourcefile \"%s\" (%s)",
  2623.             source, strerror(errno));
  2624.     if (n == 0) {
  2625.         close(fd);
  2626.         samefile = FALSE;
  2627.         nextfile++;
  2628.         if (lexeme)
  2629.             *lexeme = '\0';
  2630.         len = 0;
  2631.         goto again;
  2632.     }
  2633.     lexptr = buf + SLOP;
  2634.     lexend = lexptr + n;
  2635.     return buf;
  2636. }
  2637.  
  2638. /* tokadd --- add a character to the token buffer */
  2639.  
  2640. #define    tokadd(x) (*tok++ = (x), tok == tokend ? tokexpand() : tok)
  2641.  
  2642. /* tokexpand --- grow the token buffer */
  2643.  
  2644. char *
  2645. tokexpand()
  2646. {
  2647.     static int toksize = 60;
  2648.     int tokoffset;
  2649.  
  2650.     tokoffset = tok - tokstart;
  2651.     toksize *= 2;
  2652.     if (tokstart != NULL)
  2653.         erealloc(tokstart, char *, toksize, "tokexpand");
  2654.     else
  2655.         emalloc(tokstart, char *, toksize, "tokexpand");
  2656.     tokend = tokstart + toksize;
  2657.     tok = tokstart + tokoffset;
  2658.     return tok;
  2659. }
  2660.  
  2661. /* nextc --- get the next input character */
  2662.  
  2663. #if DEBUG
  2664. int
  2665. nextc()
  2666. {
  2667.     int c;
  2668.  
  2669.     if (lexptr && lexptr < lexend)
  2670.         c = *lexptr++;
  2671.     else if (get_src_buf())
  2672.         c = *lexptr++;
  2673.     else
  2674.         c = EOF;
  2675.  
  2676.     return c;
  2677. }
  2678. #else
  2679. #define    nextc()    ((lexptr && lexptr < lexend) ? \
  2680.             *lexptr++ : \
  2681.             (get_src_buf() ? *lexptr++ : EOF) \
  2682.         )
  2683. #endif
  2684.  
  2685. /* pushback --- push a character back on the input */
  2686.  
  2687. #define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
  2688.  
  2689. /* allow_newline --- allow newline after &&, ||, ? and : */
  2690.  
  2691. static void
  2692. allow_newline()
  2693. {
  2694.     int c;
  2695.  
  2696.     for (;;) {
  2697.         c = nextc();
  2698.         if (c == EOF)
  2699.             break;
  2700.         if (c == '#') {
  2701.             while ((c = nextc()) != '\n' && c != EOF)
  2702.                 continue;
  2703.             if (c == EOF)
  2704.                 break;
  2705.         }
  2706.         if (c == '\n')
  2707.             sourceline++;
  2708.         if (! isspace(c)) {
  2709.             pushback();
  2710.             break;
  2711.         }
  2712.     }
  2713. }
  2714.  
  2715. /* yylex --- Read the input and turn it into tokens. */
  2716.  
  2717. static int
  2718. yylex()
  2719. {
  2720.     register int c, c1;
  2721.     int seen_e = FALSE;        /* These are for numbers */
  2722.     int seen_point = FALSE;
  2723.     int esc_seen;        /* for literal strings */
  2724.     int low, mid, high;
  2725.     static int did_newline = FALSE;
  2726.     char *tokkey;
  2727.     static int lasttok = 0, eof_warned = FALSE;
  2728.  
  2729.     if (nextc() == EOF) {
  2730.         if (lasttok != NEWLINE) {
  2731.             lasttok = NEWLINE;
  2732.             if (do_lint && ! eof_warned) {
  2733.                 warning("source file does not end in newline");
  2734.                 eof_warned = TRUE;
  2735.             }
  2736.             return NEWLINE;    /* fake it */
  2737.         }
  2738.         return 0;
  2739.     }
  2740.     pushback();
  2741. #ifdef OS2
  2742.     /*
  2743.      * added for OS/2's extproc feature of cmd.exe
  2744.      * (like #! in BSD sh)
  2745.      */
  2746.     if (strncasecmp(lexptr, "extproc ", 8) == 0) {
  2747.         while (*lexptr && *lexptr != '\n')
  2748.             lexptr++;
  2749.     }
  2750. #endif
  2751.     lexeme = lexptr;
  2752.     thisline = NULL;
  2753.     if (want_regexp) {
  2754.         int in_brack = 0;    /* count brackets, [[:alnum:]] allowed */
  2755.         /*
  2756.          * Counting brackets is non-trivial. [[] is ok,
  2757.          * and so is [\]], with a point being that /[/]/ as a regexp
  2758.          * constant has to work.
  2759.          *
  2760.          * Do not count [ or ] if either one is preceded by a \.
  2761.          * A `[' should be counted if
  2762.          *  a) it is the first one so far (in_brack == 0)
  2763.          *  b) it is the `[' in `[:'
  2764.          * A ']' should be counted if not preceded by a \, since
  2765.          * it is either closing `:]' or just a plain list.
  2766.          * According to POSIX, []] is how you put a ] into a set.
  2767.          * Try to handle that too.
  2768.          *
  2769.          * The code for \ handles \[ and \].
  2770.          */
  2771.  
  2772.         want_regexp = FALSE;
  2773.         tok = tokstart;
  2774.         for (;;) {
  2775.             c = nextc();
  2776.             switch (c) {
  2777.             case '[':
  2778.                 /* one day check for `.' and `=' too */
  2779.                 if ((c1 = nextc()) == ':' || in_brack == 0)
  2780.                     in_brack++;
  2781.                 pushback();
  2782.                 break;
  2783.             case ']':
  2784.                 if (tokstart[0] == '['
  2785.                     && (tok == tokstart + 1
  2786.                     || (tok == tokstart + 2
  2787.                         && tokstart[1] == '^')))
  2788.                     /* do nothing */;
  2789.                 else
  2790.                     in_brack--;
  2791.                 break;
  2792.             case '\\':
  2793.                 if ((c = nextc()) == EOF) {
  2794.                     yyerror("unterminated regexp ends with \\ at end of file");
  2795.                     return lasttok = REGEXP; /* kludge */
  2796.                 } else if (c == '\n') {
  2797.                     sourceline++;
  2798.                     continue;
  2799.                 } else {
  2800.                     tokadd('\\');
  2801.                     tokadd(c);
  2802.                     continue;
  2803.                 }
  2804.                 break;
  2805.             case '/':    /* end of the regexp */
  2806.                 if (in_brack > 0)
  2807.                     break;
  2808.  
  2809.                 pushback();
  2810.                 tokadd('\0');
  2811.                 yylval.sval = tokstart;
  2812.                 return lasttok = REGEXP;
  2813.             case '\n':
  2814.                 pushback();
  2815.                 yyerror("unterminated regexp");
  2816.                 return lasttok = REGEXP;    /* kludge */
  2817.             case EOF:
  2818.                 yyerror("unterminated regexp at end of file");
  2819.                 return lasttok = REGEXP;    /* kludge */
  2820.             }
  2821.             tokadd(c);
  2822.         }
  2823.     }
  2824. retry:
  2825.     while ((c = nextc()) == ' ' || c == '\t')
  2826.         continue;
  2827.  
  2828.     lexeme = lexptr ? lexptr - 1 : lexptr;
  2829.     thisline = NULL;
  2830.     tok = tokstart;
  2831.     yylval.nodetypeval = Node_illegal;
  2832.  
  2833.     switch (c) {
  2834.     case EOF:
  2835.         if (lasttok != NEWLINE) {
  2836.             lasttok = NEWLINE;
  2837.             if (do_lint && ! eof_warned) {
  2838.                 warning("source file does not end in newline");
  2839.                 eof_warned = TRUE;
  2840.             }
  2841.             return NEWLINE;    /* fake it */
  2842.         }
  2843.         return 0;
  2844.  
  2845.     case '\n':
  2846.         sourceline++;
  2847.         return lasttok = NEWLINE;
  2848.  
  2849.     case '#':        /* it's a comment */
  2850.         while ((c = nextc()) != '\n') {
  2851.             if (c == EOF) {
  2852.                 if (lasttok != NEWLINE) {
  2853.                     lasttok = NEWLINE;
  2854.                     if (do_lint && ! eof_warned) {
  2855.                         warning(
  2856.                 "source file does not end in newline");
  2857.                         eof_warned = TRUE;
  2858.                     }
  2859.                     return NEWLINE;    /* fake it */
  2860.                 }
  2861.                 return 0;
  2862.             }
  2863.         }
  2864.         sourceline++;
  2865.         return lasttok = NEWLINE;
  2866.  
  2867.     case '\\':
  2868. #ifdef RELAXED_CONTINUATION
  2869.         /*
  2870.          * This code puports to allow comments and/or whitespace
  2871.          * after the `\' at the end of a line used for continuation.
  2872.          * Use it at your own risk. We think it's a bad idea, which
  2873.          * is why it's not on by default.
  2874.          */
  2875.         if (! do_traditional) {
  2876.             /* strip trailing white-space and/or comment */
  2877.             while ((c = nextc()) == ' ' || c == '\t')
  2878.                 continue;
  2879.             if (c == '#') {
  2880.                 if (do_lint)
  2881.                     warning(
  2882.         "use of `\\ #...' line continuation is not portable");
  2883.                 while ((c = nextc()) != '\n')
  2884.                     if (c == EOF)
  2885.                         break;
  2886.             }
  2887.             pushback();
  2888.         }
  2889. #endif /* RELAXED_CONTINUATION */
  2890.         if (nextc() == '\n') {
  2891.             sourceline++;
  2892.             goto retry;
  2893.         } else
  2894.             yyerror("backslash not last character on line");
  2895.         break;
  2896.  
  2897.     case '$':
  2898.         want_assign = TRUE;
  2899.         return lasttok = '$';
  2900.  
  2901.     case ':':
  2902.     case '?':
  2903.         allow_newline();
  2904.         /* fall through */
  2905.     case ')':
  2906.     case ']':
  2907.     case '(':    
  2908.     case '[':
  2909.     case ';':
  2910.     case '{':
  2911.     case ',':
  2912.         return lasttok = c;
  2913.  
  2914.     case '*':
  2915.         if ((c = nextc()) == '=') {
  2916.             yylval.nodetypeval = Node_assign_times;
  2917.             return lasttok = ASSIGNOP;
  2918.         } else if (do_posix) {
  2919.             pushback();
  2920.             return lasttok = '*';
  2921.         } else if (c == '*') {
  2922.             /* make ** and **= aliases for ^ and ^= */
  2923.             static int did_warn_op = FALSE, did_warn_assgn = FALSE;
  2924.  
  2925.             if (nextc() == '=') {
  2926.                 if (do_lint && ! did_warn_assgn) {
  2927.                     did_warn_assgn = TRUE;
  2928.                     warning("**= is not allowed by POSIX");
  2929.                     warning("operator `**=' is not supported in old awk");
  2930.                 }
  2931.                 yylval.nodetypeval = Node_assign_exp;
  2932.                 return ASSIGNOP;
  2933.             } else {
  2934.                 pushback();
  2935.                 if (do_lint && ! did_warn_op) {
  2936.                     did_warn_op = TRUE;
  2937.                     warning("** is not allowed by POSIX");
  2938.                     warning("operator `**' is not supported in old awk");
  2939.                 }
  2940.                 return lasttok = '^';
  2941.             }
  2942.         }
  2943.         pushback();
  2944.         return lasttok = '*';
  2945.  
  2946.     case '/':
  2947.         if (want_assign) {
  2948.             if (nextc() == '=') {
  2949.                 yylval.nodetypeval = Node_assign_quotient;
  2950.                 return lasttok = ASSIGNOP;
  2951.             }
  2952.             pushback();
  2953.         }
  2954.         return lasttok = '/';
  2955.  
  2956.     case '%':
  2957.         if (nextc() == '=') {
  2958.             yylval.nodetypeval = Node_assign_mod;
  2959.             return lasttok = ASSIGNOP;
  2960.         }
  2961.         pushback();
  2962.         return lasttok = '%';
  2963.  
  2964.     case '^':
  2965.     {
  2966.         static int did_warn_op = FALSE, did_warn_assgn = FALSE;
  2967.  
  2968.         if (nextc() == '=') {
  2969.             if (do_lint && ! did_warn_assgn) {
  2970.                 did_warn_assgn = TRUE;
  2971.                 warning("operator `^=' is not supported in old awk");
  2972.             }
  2973.             yylval.nodetypeval = Node_assign_exp;
  2974.             return lasttok = ASSIGNOP;
  2975.         }
  2976.         pushback();
  2977.         if (do_lint && ! did_warn_op) {
  2978.             did_warn_op = TRUE;
  2979.             warning("operator `^' is not supported in old awk");
  2980.         }
  2981.         return lasttok = '^';
  2982.     }
  2983.  
  2984.     case '+':
  2985.         if ((c = nextc()) == '=') {
  2986.             yylval.nodetypeval = Node_assign_plus;
  2987.             return lasttok = ASSIGNOP;
  2988.         }
  2989.         if (c == '+')
  2990.             return lasttok = INCREMENT;
  2991.         pushback();
  2992.         return lasttok = '+';
  2993.  
  2994.     case '!':
  2995.         if ((c = nextc()) == '=') {
  2996.             yylval.nodetypeval = Node_notequal;
  2997.             return lasttok = RELOP;
  2998.         }
  2999.         if (c == '~') {
  3000.             yylval.nodetypeval = Node_nomatch;
  3001.             want_assign = FALSE;
  3002.             return lasttok = MATCHOP;
  3003.         }
  3004.         pushback();
  3005.         return lasttok = '!';
  3006.  
  3007.     case '<':
  3008.         if (nextc() == '=') {
  3009.             yylval.nodetypeval = Node_leq;
  3010.             return lasttok = RELOP;
  3011.         }
  3012.         yylval.nodetypeval = Node_less;
  3013.         pushback();
  3014.         return lasttok = '<';
  3015.  
  3016.     case '=':
  3017.         if (nextc() == '=') {
  3018.             yylval.nodetypeval = Node_equal;
  3019.             return lasttok = RELOP;
  3020.         }
  3021.         yylval.nodetypeval = Node_assign;
  3022.         pushback();
  3023.         return lasttok = ASSIGNOP;
  3024.  
  3025.     case '>':
  3026.         if ((c = nextc()) == '=') {
  3027.             yylval.nodetypeval = Node_geq;
  3028.             return lasttok = RELOP;
  3029.         } else if (c == '>') {
  3030.             yylval.nodetypeval = Node_redirect_append;
  3031.             return lasttok = APPEND_OP;
  3032.         }
  3033.         yylval.nodetypeval = Node_greater;
  3034.         pushback();
  3035.         return lasttok = '>';
  3036.  
  3037.     case '~':
  3038.         yylval.nodetypeval = Node_match;
  3039.         want_assign = FALSE;
  3040.         return lasttok = MATCHOP;
  3041.  
  3042.     case '}':
  3043.         /*
  3044.          * Added did newline stuff.  Easier than
  3045.          * hacking the grammar.
  3046.          */
  3047.         if (did_newline) {
  3048.             did_newline = FALSE;
  3049.             return lasttok = c;
  3050.         }
  3051.         did_newline++;
  3052.         --lexptr;    /* pick up } next time */
  3053.         return lasttok = NEWLINE;
  3054.  
  3055.     case '"':
  3056.         esc_seen = FALSE;
  3057.         while ((c = nextc()) != '"') {
  3058.             if (c == '\n') {
  3059.                 pushback();
  3060.                 yyerror("unterminated string");
  3061.             }
  3062.             if (c == '\\') {
  3063.                 c = nextc();
  3064.                 if (c == '\n') {
  3065.                     sourceline++;
  3066.                     continue;
  3067.                 }
  3068.                 esc_seen = TRUE;
  3069.                 tokadd('\\');
  3070.             }
  3071.             if (c == EOF) {
  3072.                 pushback();
  3073.                 yyerror("unterminated string");
  3074.             }
  3075.             tokadd(c);
  3076.         }
  3077.         yylval.nodeval = make_str_node(tokstart,
  3078.                     tok - tokstart, esc_seen ? SCAN : 0);
  3079.         yylval.nodeval->flags |= PERM;
  3080.         return lasttok = YSTRING;
  3081.  
  3082.     case '-':
  3083.         if ((c = nextc()) == '=') {
  3084.             yylval.nodetypeval = Node_assign_minus;
  3085.             return lasttok = ASSIGNOP;
  3086.         }
  3087.         if (c == '-')
  3088.             return lasttok = DECREMENT;
  3089.         pushback();
  3090.         return lasttok = '-';
  3091.  
  3092.     case '.':
  3093.         c = nextc();
  3094.         pushback();
  3095.         if (! isdigit(c))
  3096.             return lasttok = '.';
  3097.         else
  3098.             c = '.';
  3099.         /* FALL THROUGH */
  3100.     case '0':
  3101.     case '1':
  3102.     case '2':
  3103.     case '3':
  3104.     case '4':
  3105.     case '5':
  3106.     case '6':
  3107.     case '7':
  3108.     case '8':
  3109.     case '9':
  3110.         /* It's a number */
  3111.         for (;;) {
  3112.             int gotnumber = FALSE;
  3113.  
  3114.             tokadd(c);
  3115.             switch (c) {
  3116.             case '.':
  3117.                 if (seen_point) {
  3118.                     gotnumber = TRUE;
  3119.                     break;
  3120.                 }
  3121.                 seen_point = TRUE;
  3122.                 break;
  3123.             case 'e':
  3124.             case 'E':
  3125.                 if (seen_e) {
  3126.                     gotnumber = TRUE;
  3127.                     break;
  3128.                 }
  3129.                 seen_e = TRUE;
  3130.                 if ((c = nextc()) == '-' || c == '+')
  3131.                     tokadd(c);
  3132.                 else
  3133.                     pushback();
  3134.                 break;
  3135.             case '0':
  3136.             case '1':
  3137.             case '2':
  3138.             case '3':
  3139.             case '4':
  3140.             case '5':
  3141.             case '6':
  3142.             case '7':
  3143.             case '8':
  3144.             case '9':
  3145.                 break;
  3146.             default:
  3147.                 gotnumber = TRUE;
  3148.             }
  3149.             if (gotnumber)
  3150.                 break;
  3151.             c = nextc();
  3152.         }
  3153.         if (c != EOF)
  3154.             pushback();
  3155.         else if (do_lint && ! eof_warned) {
  3156.             warning("source file does not end in newline");
  3157.             eof_warned = TRUE;
  3158.         }
  3159.         tokadd('\0');
  3160.         yylval.nodeval = make_number(atof(tokstart));
  3161.         yylval.nodeval->flags |= PERM;
  3162.         return lasttok = YNUMBER;
  3163.  
  3164.     case '&':
  3165.         if ((c = nextc()) == '&') {
  3166.             yylval.nodetypeval = Node_and;
  3167.             allow_newline();
  3168.             want_assign = FALSE;
  3169.             return lasttok = LEX_AND;
  3170.         }
  3171.         pushback();
  3172.         return lasttok = '&';
  3173.  
  3174.     case '|':
  3175.         if ((c = nextc()) == '|') {
  3176.             yylval.nodetypeval = Node_or;
  3177.             allow_newline();
  3178.             want_assign = FALSE;
  3179.             return lasttok = LEX_OR;
  3180.         }
  3181.         pushback();
  3182.         return lasttok = '|';
  3183.     }
  3184.  
  3185.     if (c != '_' && ! isalpha(c))
  3186.         yyerror("Invalid char '%c' in expression\n", c);
  3187.  
  3188.     /* it's some type of name-type-thing.  Find its length. */
  3189.     tok = tokstart;
  3190.     while (is_identchar(c)) {
  3191.         tokadd(c);
  3192.         c = nextc();
  3193.     }
  3194.     tokadd('\0');
  3195.     emalloc(tokkey, char *, tok - tokstart, "yylex");
  3196.     memcpy(tokkey, tokstart, tok - tokstart);
  3197.     if (c != EOF)
  3198.         pushback();
  3199.     else if (do_lint && ! eof_warned) {
  3200.         warning("source file does not end in newline");
  3201.         eof_warned = TRUE;
  3202.     }
  3203.  
  3204.     /* See if it is a special token. */
  3205.     low = 0;
  3206.     high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1;
  3207.     while (low <= high) {
  3208.         int i;
  3209.  
  3210.         mid = (low + high) / 2;
  3211.         c = *tokstart - tokentab[mid].operator[0];
  3212.         i = c ? c : strcmp(tokstart, tokentab[mid].operator);
  3213.  
  3214.         if (i < 0)        /* token < mid */
  3215.             high = mid - 1;
  3216.         else if (i > 0)        /* token > mid */
  3217.             low = mid + 1;
  3218.         else {
  3219.             if (do_lint) {
  3220.                 if (tokentab[mid].flags & GAWKX)
  3221.                     warning("%s() is a gawk extension",
  3222.                         tokentab[mid].operator);
  3223.                 if (tokentab[mid].flags & RESX)
  3224.                     warning("%s() is a Bell Labs extension",
  3225.                         tokentab[mid].operator);
  3226.                 if (tokentab[mid].flags & NOT_POSIX)
  3227.                     warning("POSIX does not allow %s",
  3228.                         tokentab[mid].operator);
  3229.             }
  3230.             if (do_lint_old && (tokentab[mid].flags & NOT_OLD))
  3231.                 warning("%s is not supported in old awk",
  3232.                         tokentab[mid].operator);
  3233.             if ((do_traditional && (tokentab[mid].flags & GAWKX))
  3234.                 || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
  3235.                 break;
  3236.             if (tokentab[mid].class == LEX_BUILTIN
  3237.                 || tokentab[mid].class == LEX_LENGTH
  3238.                )
  3239.                 yylval.lval = mid;
  3240.             else
  3241.                 yylval.nodetypeval = tokentab[mid].value;
  3242.  
  3243.             free(tokkey);
  3244.             return lasttok = tokentab[mid].class;
  3245.         }
  3246.     }
  3247.  
  3248.     yylval.sval = tokkey;
  3249.     if (*lexptr == '(')
  3250.         return lasttok = FUNC_CALL;
  3251.     else {
  3252.         want_assign = TRUE;
  3253.         return lasttok = NAME;
  3254.     }
  3255. }
  3256.  
  3257. /* node_common --- common code for allocating a new node */
  3258.  
  3259. static NODE *
  3260. node_common(op)
  3261. NODETYPE op;
  3262. {
  3263.     register NODE *r;
  3264.  
  3265.     getnode(r);
  3266.     r->type = op;
  3267.     r->flags = MALLOC;
  3268.     /* if lookahead is NL, lineno is 1 too high */
  3269.     if (lexeme && *lexeme == '\n')
  3270.         r->source_line = sourceline - 1;
  3271.     else
  3272.         r->source_line = sourceline;
  3273.     r->source_file = source;
  3274.     return r;
  3275. }
  3276.  
  3277. /* node --- allocates a node with defined lnode and rnode. */
  3278.  
  3279. NODE *
  3280. node(left, op, right)
  3281. NODE *left, *right;
  3282. NODETYPE op;
  3283. {
  3284.     register NODE *r;
  3285.  
  3286.     r = node_common(op);
  3287.     r->lnode = left;
  3288.     r->rnode = right;
  3289.     return r;
  3290. }
  3291.  
  3292. /* snode ---    allocate a node with defined subnode and proc for builtin
  3293.         functions. Checks for arg. count and supplies defaults where
  3294.         possible. */
  3295.  
  3296. static NODE *
  3297. snode(subn, op, idx)
  3298. NODETYPE op;
  3299. int idx;
  3300. NODE *subn;
  3301. {
  3302.     register NODE *r;
  3303.     register NODE *n;
  3304.     int nexp = 0;
  3305.     int args_allowed;
  3306.  
  3307.     r = node_common(op);
  3308.  
  3309.     /* traverse expression list to see how many args. given */
  3310.     for (n = subn; n != NULL; n = n->rnode) {
  3311.         nexp++;
  3312.         if (nexp > 3)
  3313.             break;
  3314.     }
  3315.  
  3316.     /* check against how many args. are allowed for this builtin */
  3317.     args_allowed = tokentab[idx].flags & ARGS;
  3318.     if (args_allowed && (args_allowed & A(nexp)) == 0)
  3319.         fatal("%s() cannot have %d argument%c",
  3320.             tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's');
  3321.  
  3322.     r->proc = tokentab[idx].ptr;
  3323.  
  3324.     /* special case processing for a few builtins */
  3325.     if (nexp == 0 && r->proc == do_length) {
  3326.         subn = node(node(make_number(0.0), Node_field_spec, (NODE *) NULL),
  3327.                     Node_expression_list,
  3328.                 (NODE *) NULL);
  3329.     } else if (r->proc == do_match) {
  3330.         if (subn->rnode->lnode->type != Node_regex)
  3331.             subn->rnode->lnode = mk_rexp(subn->rnode->lnode);
  3332.     } else if (r->proc == do_sub || r->proc == do_gsub) {
  3333.         if (subn->lnode->type != Node_regex)
  3334.             subn->lnode = mk_rexp(subn->lnode);
  3335.         if (nexp == 2)
  3336.             append_right(subn, node(node(make_number(0.0),
  3337.                              Node_field_spec,
  3338.                              (NODE *) NULL),
  3339.                             Node_expression_list,
  3340.                         (NODE *) NULL));
  3341.         else if (do_lint && subn->rnode->rnode->lnode->type == Node_val)
  3342.             warning("string literal as last arg of substitute");
  3343.     } else if (r->proc == do_gensub) {
  3344.         if (subn->lnode->type != Node_regex)
  3345.             subn->lnode = mk_rexp(subn->lnode);
  3346.         if (nexp == 3)
  3347.             append_right(subn, node(node(make_number(0.0),
  3348.                              Node_field_spec,
  3349.                              (NODE *) NULL),
  3350.                             Node_expression_list,
  3351.                         (NODE *) NULL));
  3352.     } else if (r->proc == do_split) {
  3353.         if (nexp == 2)
  3354.             append_right(subn,
  3355.                 node(FS_node, Node_expression_list, (NODE *) NULL));
  3356.         n = subn->rnode->rnode->lnode;
  3357.         if (n->type != Node_regex)
  3358.             subn->rnode->rnode->lnode = mk_rexp(n);
  3359.         if (nexp == 2)
  3360.             subn->rnode->rnode->lnode->re_flags |= FS_DFLT;
  3361.     }
  3362.  
  3363.     r->subnode = subn;
  3364.     return r;
  3365. }
  3366.  
  3367. /*
  3368.  * mkrangenode:
  3369.  * This allocates a Node_line_range node with defined condpair and
  3370.  * zeroes the trigger word to avoid the temptation of assuming that calling
  3371.  * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'. 
  3372.  * Otherwise like node().
  3373.  */
  3374.  
  3375. static NODE *
  3376. mkrangenode(cpair)
  3377. NODE *cpair;
  3378. {
  3379.     register NODE *r;
  3380.  
  3381.     getnode(r);
  3382.     r->type = Node_line_range;
  3383.     r->condpair = cpair;
  3384.     r->triggered = FALSE;
  3385.     return r;
  3386. }
  3387.  
  3388. /* make_for_loop --- build a for loop */
  3389.  
  3390. static NODE *
  3391. make_for_loop(init, cond, incr)
  3392. NODE *init, *cond, *incr;
  3393. {
  3394.     register FOR_LOOP_HEADER *r;
  3395.     NODE *n;
  3396.  
  3397.     emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
  3398.     getnode(n);
  3399.     n->type = Node_illegal;
  3400.     r->init = init;
  3401.     r->cond = cond;
  3402.     r->incr = incr;
  3403.     n->sub.nodep.r.hd = r;
  3404.     return n;
  3405. }
  3406.  
  3407. /* dup_parms --- return TRUE if there are duplicate parameters */
  3408.  
  3409. static int
  3410. dup_parms(func)
  3411. NODE *func;
  3412. {
  3413.     register NODE *np;
  3414.     char *fname, **names;
  3415.     int count, i, j, dups;
  3416.     NODE *params;
  3417.  
  3418.     fname = func->param;
  3419.     count = func->param_cnt;
  3420.     params = func->rnode;
  3421.  
  3422.     if (count == 0)        /* no args, no problem */
  3423.         return FALSE;
  3424.  
  3425.     emalloc(names, char **, count * sizeof(char *), "dup_parms");
  3426.  
  3427.     i = 0;
  3428.     for (np = params; np != NULL; np = np->rnode)
  3429.         names[i++] = np->param;
  3430.  
  3431.     dups = 0;
  3432.     for (i = 1; i < count; i++) {
  3433.         for (j = 0; j < i; j++) {
  3434.             if (strcmp(names[i], names[j]) == 0) {
  3435.                 dups++;
  3436.                 error(
  3437.     "function `%s': parameter #%d, `%s', duplicates parameter #%d",
  3438.                     fname, i+1, names[j], j+1);
  3439.             }
  3440.         }
  3441.     }
  3442.  
  3443.     free(names);
  3444.     return (dups > 0 ? TRUE : FALSE);
  3445. }
  3446.  
  3447. /*
  3448.  * install:
  3449.  * Install a name in the symbol table, even if it is already there.
  3450.  * Caller must check against redefinition if that is desired. 
  3451.  */
  3452.  
  3453. NODE *
  3454. install(name, value)
  3455. char *name;
  3456. NODE *value;
  3457. {
  3458.     register NODE *hp;
  3459.     register size_t len;
  3460.     register int bucket;
  3461.  
  3462.     len = strlen(name);
  3463.     bucket = hash(name, len, (unsigned long) HASHSIZE);
  3464.     getnode(hp);
  3465.     hp->type = Node_hashnode;
  3466.     hp->hnext = variables[bucket];
  3467.     variables[bucket] = hp;
  3468.     hp->hlength = len;
  3469.     hp->hvalue = value;
  3470.     hp->hname = name;
  3471.     hp->hvalue->vname = name;
  3472.     return hp->hvalue;
  3473. }
  3474.  
  3475. /* lookup --- find the most recent hash node for name installed by install */
  3476.  
  3477. NODE *
  3478. lookup(name)
  3479. const char *name;
  3480. {
  3481.     register NODE *bucket;
  3482.     register size_t len;
  3483.  
  3484.     len = strlen(name);
  3485.     for (bucket = variables[hash(name, len, (unsigned long) HASHSIZE)];
  3486.             bucket != NULL; bucket = bucket->hnext)
  3487.         if (bucket->hlength == len && STREQN(bucket->hname, name, len))
  3488.             return bucket->hvalue;
  3489.  
  3490.     return NULL;
  3491. }
  3492.  
  3493. /*
  3494.  * append_right:
  3495.  * Add new to the rightmost branch of LIST.  This uses n^2 time, so we make
  3496.  * a simple attempt at optimizing it.
  3497.  */
  3498.  
  3499. static NODE *
  3500. append_right(list, new)
  3501. NODE *list, *new;
  3502. {
  3503.     register NODE *oldlist;
  3504.     static NODE *savefront = NULL, *savetail = NULL;
  3505.  
  3506.     oldlist = list;
  3507.     if (savefront == oldlist) {
  3508.         savetail = savetail->rnode = new;
  3509.         return oldlist;
  3510.     } else
  3511.         savefront = oldlist;
  3512.     while (list->rnode != NULL)
  3513.         list = list->rnode;
  3514.     savetail = list->rnode = new;
  3515.     return oldlist;
  3516. }
  3517.  
  3518. /*
  3519.  * func_install:
  3520.  * check if name is already installed;  if so, it had better have Null value,
  3521.  * in which case def is added as the value. Otherwise, install name with def
  3522.  * as value. 
  3523.  */
  3524.  
  3525. static void
  3526. func_install(params, def)
  3527. NODE *params;
  3528. NODE *def;
  3529. {
  3530.     NODE *r;
  3531.  
  3532.     pop_params(params->rnode);
  3533.     pop_var(params, FALSE);
  3534.     r = lookup(params->param);
  3535.     if (r != NULL) {
  3536.         fatal("function name `%s' previously defined", params->param);
  3537.     } else
  3538.         (void) install(params->param, node(params, Node_func, def));
  3539.  
  3540.     func_use(params->param, FUNC_DEFINE);
  3541. }
  3542.  
  3543. /* pop_var --- remove a variable from the symbol table */
  3544.  
  3545. static void
  3546. pop_var(np, freeit)
  3547. NODE *np;
  3548. int freeit;
  3549. {
  3550.     register NODE *bucket, **save;
  3551.     register size_t len;
  3552.     char *name;
  3553.  
  3554.     name = np->param;
  3555.     len = strlen(name);
  3556.     save = &(variables[hash(name, len, (unsigned long) HASHSIZE)]);
  3557.     for (bucket = *save; bucket != NULL; bucket = bucket->hnext) {
  3558.         if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
  3559.             *save = bucket->hnext;
  3560.             freenode(bucket);
  3561.             if (freeit)
  3562.                 free(np->param);
  3563.             return;
  3564.         }
  3565.         save = &(bucket->hnext);
  3566.     }
  3567. }
  3568.  
  3569. /* pop_params --- remove list of function parameters from symbol table */
  3570.  
  3571. /*
  3572.  * pop parameters out of the symbol table. do this in reverse order to
  3573.  * avoid reading freed memory if there were duplicated parameters.
  3574.  */
  3575. static void
  3576. pop_params(params)
  3577. NODE *params;
  3578. {
  3579.     if (params == NULL)
  3580.         return;
  3581.     pop_params(params->rnode);
  3582.     pop_var(params, TRUE);
  3583. }
  3584.  
  3585. /* make_param --- make NAME into a function parameter */
  3586.  
  3587. static NODE *
  3588. make_param(name)
  3589. char *name;
  3590. {
  3591.     NODE *r;
  3592.  
  3593.     getnode(r);
  3594.     r->type = Node_param_list;
  3595.     r->rnode = NULL;
  3596.     r->param = name;
  3597.     r->param_cnt = param_counter++;
  3598.     return (install(name, r));
  3599. }
  3600.  
  3601. static struct fdesc {
  3602.     char *name;
  3603.     short used;
  3604.     short defined;
  3605.     struct fdesc *next;
  3606. } *ftable[HASHSIZE];
  3607.  
  3608. /* func_use --- track uses and definitions of functions */
  3609.  
  3610. static void
  3611. func_use(name, how)
  3612. char *name;
  3613. enum defref how;
  3614. {
  3615.     struct fdesc *fp;
  3616.     int len;
  3617.     int ind;
  3618.  
  3619.     len = strlen(name);
  3620.     ind = hash(name, len, HASHSIZE);
  3621.  
  3622.     for (fp = ftable[ind]; fp != NULL; fp = fp->next) {
  3623.         if (strcmp(fp->name, name) == 0) {
  3624.             if (how == FUNC_DEFINE)
  3625.                 fp->defined++;
  3626.             else
  3627.                 fp->used++;
  3628.             return;
  3629.         }
  3630.     }
  3631.  
  3632.     /* not in the table, fall through to allocate a new one */
  3633.  
  3634.     emalloc(fp, struct fdesc *, sizeof(struct fdesc), "func_use");
  3635.     memset(fp, '\0', sizeof(struct fdesc));
  3636.     emalloc(fp->name, char *, len + 1, "func_use");
  3637.     strcpy(fp->name, name);
  3638.     if (how == FUNC_DEFINE)
  3639.         fp->defined++;
  3640.     else
  3641.         fp->used++;
  3642.     fp->next = ftable[ind];
  3643.     ftable[ind] = fp;
  3644. }
  3645.  
  3646. /* check_funcs --- verify functions that are called but not defined */
  3647.  
  3648. static void
  3649. check_funcs()
  3650. {
  3651.     struct fdesc *fp, *next;
  3652.     int i;
  3653.  
  3654.     for (i = 0; i < HASHSIZE; i++) {
  3655.         for (fp = ftable[i]; fp != NULL; fp = fp->next) {
  3656. #ifdef REALLYMEAN
  3657.             /* making this the default breaks old code. sigh. */
  3658.             if (fp->defined == 0) {
  3659.                 error(
  3660.         "function `%s' called but never defined", fp->name);
  3661.                 errcount++;
  3662.             }
  3663. #else
  3664.             if (do_lint && fp->defined == 0)
  3665.                 warning(
  3666.         "function `%s' called but never defined", fp->name);
  3667. #endif
  3668.             if (do_lint && fp->used == 0) {
  3669.                 warning("function `%s' defined but never called",
  3670.                     fp->name);
  3671.             }
  3672.         }
  3673.     }
  3674.  
  3675.     /* now let's free all the memory */
  3676.     for (i = 0; i < HASHSIZE; i++) {
  3677.         for (fp = ftable[i]; fp != NULL; fp = next) {
  3678.             next = fp->next;
  3679.             free(fp->name);
  3680.             free(fp);
  3681.         }
  3682.     }
  3683. }
  3684.  
  3685. /* param_sanity --- look for parameters that are regexp constants */
  3686.  
  3687. static void
  3688. param_sanity(arglist)
  3689. NODE *arglist;
  3690. {
  3691.     NODE *argp, *arg;
  3692.     int i;
  3693.  
  3694.     for (i = 1, argp = arglist; argp != NULL; argp = argp->rnode, i++) {
  3695.         arg = argp->lnode;
  3696.         if (arg->type == Node_regex)
  3697.             warning("regexp constant for parameter #%d yields boolean value", i);
  3698.     }
  3699. }
  3700.  
  3701. /* variable --- make sure NAME is in the symbol table */
  3702.  
  3703. NODE *
  3704. variable(name, can_free, type)
  3705. char *name;
  3706. int can_free;
  3707. NODETYPE type;
  3708. {
  3709.     register NODE *r;
  3710.     static int env_loaded = FALSE;
  3711.  
  3712.     if (! env_loaded && STREQ(name, "ENVIRON")) {
  3713.         load_environ();
  3714.         env_loaded = TRUE;
  3715.     }
  3716.     if ((r = lookup(name)) == NULL)
  3717.         r = install(name, node(Nnull_string, type, (NODE *) NULL));
  3718.     else if (can_free)
  3719.         free(name);
  3720.     return r;
  3721. }
  3722.  
  3723. /* mk_rexp --- make a regular expression constant */
  3724.  
  3725. static NODE *
  3726. mk_rexp(exp)
  3727. NODE *exp;
  3728. {
  3729.     NODE *n;
  3730.  
  3731.     if (exp->type == Node_regex)
  3732.         return exp;
  3733.  
  3734.     getnode(n);
  3735.     n->type = Node_regex;
  3736.     n->re_exp = exp;
  3737.     n->re_text = NULL;
  3738.     n->re_reg = NULL;
  3739.     n->re_flags = 0;
  3740.     n->re_cnt = 1;
  3741.     return n;
  3742. }
  3743.  
  3744. /* isnoeffect --- when used as a statement, has no side effects */
  3745.  
  3746. /*
  3747.  * To be completely general, we should recursively walk the parse
  3748.  * tree, to make sure that all the subexpressions also have no effect.
  3749.  * Instead, we just weaken the actual warning that's printed, up above
  3750.  * in the grammar.
  3751.  */
  3752.  
  3753. static int
  3754. isnoeffect(type)
  3755. NODETYPE type;
  3756. {
  3757.     switch (type) {
  3758.     case Node_times:
  3759.     case Node_quotient:
  3760.     case Node_mod:
  3761.     case Node_plus:
  3762.     case Node_minus:
  3763.     case Node_subscript:
  3764.     case Node_concat:
  3765.     case Node_exp:
  3766.     case Node_unary_minus:
  3767.     case Node_field_spec:
  3768.     case Node_and:
  3769.     case Node_or:
  3770.     case Node_equal:
  3771.     case Node_notequal:
  3772.     case Node_less:
  3773.     case Node_greater:
  3774.     case Node_leq:
  3775.     case Node_geq:
  3776.     case Node_match:
  3777.     case Node_nomatch:
  3778.     case Node_not:
  3779.     case Node_val:
  3780.     case Node_in_array:
  3781.     case Node_NF:
  3782.     case Node_NR:
  3783.     case Node_FNR:
  3784.     case Node_FS:
  3785.     case Node_RS:
  3786.     case Node_FIELDWIDTHS:
  3787.     case Node_IGNORECASE:
  3788.     case Node_OFS:
  3789.     case Node_ORS:
  3790.     case Node_OFMT:
  3791.     case Node_CONVFMT:
  3792.         return TRUE;
  3793.     default:
  3794.         break;    /* keeps gcc -Wall happy */
  3795.     }
  3796.  
  3797.     return FALSE;
  3798. }
  3799.